diff --git a/godeltaprof/compat/compression_test.go b/godeltaprof/compat/compression_test.go index ceeb4b7..f2d3cda 100644 --- a/godeltaprof/compat/compression_test.go +++ b/godeltaprof/compat/compression_test.go @@ -10,9 +10,10 @@ func BenchmarkHeapCompression(b *testing.B) { h := newHeapTestHelper() fs := h.generateMemProfileRecords(512, 32) b.ResetTimer() + nmutations := int(h.rng.Int63() % int64(len(fs))) for i := 0; i < b.N; i++ { _ = WriteHeapProto(h.dp, h.opt, io.Discard, fs, int64(runtime.MemProfileRate)) - h.mutate(fs) + h.mutate(nmutations, fs) } } diff --git a/godeltaprof/compat/delta_test.go b/godeltaprof/compat/delta_test.go index 6a122bf..4ae28ca 100644 --- a/godeltaprof/compat/delta_test.go +++ b/godeltaprof/compat/delta_test.go @@ -172,9 +172,10 @@ func BenchmarkHeapDelta(b *testing.B) { fs := h.generateMemProfileRecords(512, 32) builder := &noopBuilder{} b.ResetTimer() + nmutations := int(h.rng.Int63() % int64(len(fs))) for i := 0; i < b.N; i++ { _ = h.dp.WriteHeapProto(builder, fs, int64(runtime.MemProfileRate)) - h.mutate(fs) + h.mutate(nmutations, fs) } } diff --git a/godeltaprof/compat/testdata.go b/godeltaprof/compat/testdata.go index fc9b082..5127db0 100644 --- a/godeltaprof/compat/testdata.go +++ b/godeltaprof/compat/testdata.go @@ -295,10 +295,9 @@ func (h *heapTestHelper) r(AllocObjects, AllocBytes, FreeObjects, FreeBytes int6 } } -func (h *heapTestHelper) mutate(fs []runtime.MemProfileRecord) { - nmutations := int(h.rng.Int63() % int64(len(fs))) +func (h *heapTestHelper) mutate(n int, fs []runtime.MemProfileRecord) { objSize := fs[0].AllocBytes / fs[0].AllocObjects - for j := 0; j < nmutations; j++ { + for j := 0; j < n; j++ { idx := int(uint(h.rng.Int63())) % len(fs) fs[idx].AllocObjects += 1 fs[idx].AllocBytes += objSize