Re: [go-nuts] Sleep causes a tenfold difference in time interval

2021-11-04 Thread Robert Engels
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 >

[go-nuts] Sleep causes a tenfold difference in time interval

2021-11-04 Thread 尚义龙
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)) } } ```