Because when you sleep you deschedule the process/thread by the OS - and so the
cached code and data needs to be reloaded so operations aren’t slower until
then.
> On Nov 4, 2021, at 11:19 AM, 尚义龙 wrote:
>
>
> I was doing pressure testing in my project and found a large gap in the time
> i
I was doing pressure testing in my project and found a large gap in the
time interval due to time.Sleep, which I abstracted to the following code:
code 1:
```go
func TestSleep(t *testing.T) {
for i := 0; i < 8; i++ {
//time.Sleep(time.Second)
t1 := time.Now()
fmt.Println( time.Since(t1))
}
}
```
o