Skip to content

Commit

Permalink
Include benchmarks for set operation.
Browse files Browse the repository at this point in the history
  • Loading branch information
matttproud committed Jan 13, 2013
1 parent 683f59a commit 1f6d14d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions skiplist/skiplist_test.go
Expand Up @@ -289,6 +289,19 @@ func LookupBenchmark(b *testing.B, n int) {
}
}

func SetBenchmark(b *testing.B, n int) {
b.StopTimer()
values := []int{}
for i := 0; i < b.N; i++ {
values = append(values, rand.Int())
}
s := NewIntMap()
b.StartTimer()
for i := 0; i < b.N; i++ {
s.Set(values[i], values[i])
}
}

// Make sure that all the keys are unique and are returned in order.
func TestSanity(t *testing.T) {
s := NewIntMap()
Expand Down Expand Up @@ -487,3 +500,15 @@ func BenchmarkLookup256(b *testing.B) {
func BenchmarkLookup65536(b *testing.B) {
LookupBenchmark(b, 65536)
}

func BenchmarkSet16(b *testing.B) {
SetBenchmark(b, 16)
}

func BenchmarkSet256(b *testing.B) {
SetBenchmark(b, 256)
}

func BenchmarkSet65536(b *testing.B) {
SetBenchmark(b, 65536)
}

0 comments on commit 1f6d14d

Please sign in to comment.