From 6fe1ab45c2446aef7f46f7418c35533b86abe213 Mon Sep 17 00:00:00 2001 From: Matt Jaffee Date: Tue, 5 Mar 2019 08:47:44 -0600 Subject: [PATCH] fixup Fragment_Import benchmark It was doing a fresh import on the first round and then importing the same data into the fragment over and over. --- fragment_internal_test.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/fragment_internal_test.go b/fragment_internal_test.go index f8e88c0d2..6d1aad8c6 100644 --- a/fragment_internal_test.go +++ b/fragment_internal_test.go @@ -1904,8 +1904,7 @@ func BenchmarkFragment_FullSnapshot(b *testing.B) { } func BenchmarkFragment_Import(b *testing.B) { - f := mustOpenFragment("i", "f", viewStandard, 0, "") - defer f.Clean(b) + b.StopTimer() maxX := 1048576 * 5 * 2 sz := maxX rows := make([]uint64, sz) @@ -1924,17 +1923,19 @@ func BenchmarkFragment_Import(b *testing.B) { } } rowsUse, colsUse := make([]uint64, len(rows)), make([]uint64, len(cols)) - copy(rowsUse, rows) - copy(colsUse, cols) - b.ResetTimer() b.ReportAllocs() options := &ImportOptions{} for i := 0; i < b.N; i++ { + // since bulkImport modifies the input slices, we make new copies for each round copy(rowsUse, rows) copy(colsUse, cols) + f := mustOpenFragment("i", "f", viewStandard, 0, "") + b.StartTimer() if err := f.bulkImport(rowsUse, colsUse, options); err != nil { - b.Fatalf("Error Building Sample: %s", err) + b.Errorf("Error Building Sample: %s", err) } + b.StopTimer() + f.Clean(b) } }