提交 42f82d91 作者: Steven Allen

ci: eager GC in benchmarks

上级 895fe215
package integrationtest package integrationtest
import ( import (
"runtime"
"testing" "testing"
"github.com/ipfs/go-ipfs/thirdparty/unit" "github.com/ipfs/go-ipfs/thirdparty/unit"
...@@ -8,16 +9,17 @@ import ( ...@@ -8,16 +9,17 @@ import (
) )
func benchmarkAddCat(numBytes int64, conf testutil.LatencyConfig, b *testing.B) { 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 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++ { for n := 0; n < b.N; n++ {
if err := DirectAddCat(data, conf); err != nil { if err := DirectAddCat(data, conf); err != nil {
b.Fatal(err) b.Fatal(err)
} }
b.StopTimer()
runtime.GC()
b.StartTimer()
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论