index: add garbage collection benchmark

Allocates an index and repeatedly triggers the GC.
This commit is contained in:
Michael Eischer 2022-10-22 23:37:31 +02:00
parent ffca602315
commit 0c1240360d

View file

@ -4,6 +4,7 @@ import (
"context"
"fmt"
"math/rand"
"runtime"
"testing"
"time"
@ -323,6 +324,17 @@ func BenchmarkMasterIndexEach(b *testing.B) {
}
}
func BenchmarkMasterIndexGC(b *testing.B) {
mIdx, _ := createRandomMasterIndex(b, rand.New(rand.NewSource(0)), 100, 10000)
b.ResetTimer()
for i := 0; i < b.N; i++ {
runtime.GC()
}
runtime.KeepAlive(mIdx)
}
var (
snapshotTime = time.Unix(1470492820, 207401672)
depth = 3