func BenchmarkInsert(b *testing.B) {
	for i := 0; i < b.N; i++ {
		var tree llrb.Tree
		for i := 0; i < len(fixture.TestData); i++ {
			tree.Insert(llrbItemUnique(fixture.TestData[i]))
		}
	}
}
func BenchmarkSortedInsert_InsertNoReplace(b *testing.B) {
	for i := 0; i < b.N; i++ {
		var tree llrb.Tree
		for i := 0; i < len(fixture.SortedTestData); i++ {
			tree.Insert(llrbItemNonUnique(fixture.SortedTestData[i]))
		}
	}
}
예제 #3
0
파일: step.go 프로젝트: Huangsir/store
// deleteRangeInclusive deletes all steps within the given range.
// Note that llrb.(*Tree).DoRange does not operate on the node matching the end of a range.
func deleteRangeInclusive(t *llrb.Tree, start, end int) {
	var delQ []llrb.Comparable
	t.DoRange(func(c llrb.Comparable) (done bool) {
		delQ = append(delQ, c)
		return
	}, query(start), query(end+1))
	for _, p := range delQ {
		t.Delete(p)
	}
}
func BenchmarkIterate(b *testing.B) {
	var tree llrb.Tree
	for i := 0; i < len(fixture.TestData); i++ {
		tree.Insert(llrbItemUnique(fixture.TestData[i]))
	}
	b.ResetTimer()

	for i := 0; i < b.N; i++ {
		tree.Do(func(i llrb.Comparable) bool {
			_ = i.(llrbItemUnique).Key
			_ = i.(llrbItemUnique).Value
			return false
		})
	}
}