Skip to content

Instantly share code, notes, and snippets.

@tylertreat-wf
Last active January 5, 2016 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tylertreat-wf/86405792a6537d3a8f2e to your computer and use it in GitHub Desktop.
Save tylertreat-wf/86405792a6537d3a8f2e to your computer and use it in GitHub Desktop.
func BenchmarkInsertMulti(b *testing.B) {
ctrie := New(nil)
b.ResetTimer()
for i := 0; i < b.N; i++ {
for j := 0; j < 1000000; j++ {
ctrie.Insert([]byte(strconv.Itoa(j)), 0)
}
}
}
func BenchmarkInsertMultiWithSnapshots(b *testing.B) {
ctrie := New(nil)
b.ResetTimer()
for i := 0; i < b.N; i++ {
var wg sync.WaitGroup
wg.Add(2)
go func() {
for j := 0; j < 1000000; j++ {
ctrie.Insert([]byte(strconv.Itoa(j)), 0)
}
wg.Done()
}()
go func() {
for j := 0; j < 1000000; j++ {
ctrie.Snapshot()
}
wg.Done()
}()
wg.Wait()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment