Skip to content

Commit

Permalink
ci: eager GC in benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien authored and magik6k committed Jun 19, 2019
1 parent 2c9ea5f commit eb2527e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions test/integration/bench_test.go
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
package integrationtest

import (
"runtime"
"testing"

"github.com/ipfs/go-ipfs/thirdparty/unit"
testutil "github.com/libp2p/go-libp2p-testing/net"
)

func benchmarkAddCat(numBytes int64, conf testutil.LatencyConfig, b *testing.B) {

b.StopTimer()
b.SetBytes(numBytes)
data := RandomBytes(numBytes) // we don't want to measure the time it takes to generate this data
b.StartTimer()

b.SetBytes(numBytes)
b.ResetTimer()
for n := 0; n < b.N; n++ {
if err := DirectAddCat(data, conf); err != nil {
b.Fatal(err)
}
b.StopTimer()
runtime.GC()
b.StartTimer()
}
}

Expand Down

0 comments on commit eb2527e

Please sign in to comment.