The following benchmark is modified from https://github.com/golang/go/issues/30802
package main import ( "testing" "time" ) func SleepTest(milliseconds time.Duration) { time.Sleep(time.Millisecond * milliseconds) } func BenchmarkTestSleep_2000(b *testing.B) { for i := 0; i < b.N; i++ { SleepTest(2000) } } func BenchmarkTestSleep_1000(b *testing.B) { for i := 0; i < b.N; i++ { SleepTest(1000) } } func BenchmarkTestSleep_500(b *testing.B) { for i := 0; i < b.N; i++ { SleepTest(500) } } func BenchmarkTestSleep_100(b *testing.B) { for i := 0; i < b.N; i++ { SleepTest(100) } } func BenchmarkTestSleep_10(b *testing.B) { for i := 0; i < b.N; i++ { SleepTest(10) } } The result: $ go test -bench=. goos: linux goarch: amd64 pkg: app/t BenchmarkTestSleep_2000-4 1 2000142946 ns/op BenchmarkTestSleep_1000-4 1 1000192805 ns/op BenchmarkTestSleep_500-4 2 500191727 ns/op BenchmarkTestSleep_100-4 10 100179544 ns/op BenchmarkTestSleep_10-4 100 10164319 ns/op It is some strange that when the argument is less than 1s, the smaller it is, the more allocations. Bu, or my understanding is wrong? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.