Skip to content

Commit 4dfae6a

Browse files
Dmitrii Martynovrandall77
Dmitrii Martynov
authored andcommitted
runtime: exclude allocation(s) from memmove/memclr benchmarking
The overhead for allocation is not significant but it should be excluded from the memmove/memclr benchmarking anyway. Change-Id: I7ea86d1b85b13352ccbff16f7510caa250654dab Reviewed-on: https://go-review.googlesource.com/c/go/+/645576 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
1 parent e7cd497 commit 4dfae6a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/runtime/memmove_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ func BenchmarkMemmove(b *testing.B) {
292292
benchmarkSizes(b, bufSizes, func(b *testing.B, n int) {
293293
x := make([]byte, n)
294294
y := make([]byte, n)
295+
b.ResetTimer()
295296
for i := 0; i < b.N; i++ {
296297
copy(x, y)
297298
}
@@ -301,6 +302,7 @@ func BenchmarkMemmove(b *testing.B) {
301302
func BenchmarkMemmoveOverlap(b *testing.B) {
302303
benchmarkSizes(b, bufSizesOverlap, func(b *testing.B, n int) {
303304
x := make([]byte, n+16)
305+
b.ResetTimer()
304306
for i := 0; i < b.N; i++ {
305307
copy(x[16:n+16], x[:n])
306308
}
@@ -311,6 +313,7 @@ func BenchmarkMemmoveUnalignedDst(b *testing.B) {
311313
benchmarkSizes(b, bufSizes, func(b *testing.B, n int) {
312314
x := make([]byte, n+1)
313315
y := make([]byte, n)
316+
b.ResetTimer()
314317
for i := 0; i < b.N; i++ {
315318
copy(x[1:], y)
316319
}
@@ -320,6 +323,7 @@ func BenchmarkMemmoveUnalignedDst(b *testing.B) {
320323
func BenchmarkMemmoveUnalignedDstOverlap(b *testing.B) {
321324
benchmarkSizes(b, bufSizesOverlap, func(b *testing.B, n int) {
322325
x := make([]byte, n+16)
326+
b.ResetTimer()
323327
for i := 0; i < b.N; i++ {
324328
copy(x[16:n+16], x[1:n+1])
325329
}
@@ -330,6 +334,7 @@ func BenchmarkMemmoveUnalignedSrc(b *testing.B) {
330334
benchmarkSizes(b, bufSizes, func(b *testing.B, n int) {
331335
x := make([]byte, n)
332336
y := make([]byte, n+1)
337+
b.ResetTimer()
333338
for i := 0; i < b.N; i++ {
334339
copy(x, y[1:])
335340
}
@@ -362,6 +367,7 @@ func BenchmarkMemmoveUnalignedSrcDst(b *testing.B) {
362367
func BenchmarkMemmoveUnalignedSrcOverlap(b *testing.B) {
363368
benchmarkSizes(b, bufSizesOverlap, func(b *testing.B, n int) {
364369
x := make([]byte, n+1)
370+
b.ResetTimer()
365371
for i := 0; i < b.N; i++ {
366372
copy(x[1:n+1], x[:n])
367373
}
@@ -450,6 +456,7 @@ func BenchmarkMemclrUnaligned(b *testing.B) {
450456
func BenchmarkGoMemclr(b *testing.B) {
451457
benchmarkSizes(b, []int{5, 16, 64, 256}, func(b *testing.B, n int) {
452458
x := make([]byte, n)
459+
b.ResetTimer()
453460
for i := 0; i < b.N; i++ {
454461
clear(x)
455462
}

0 commit comments

Comments
 (0)