-
Notifications
You must be signed in to change notification settings - Fork 8
/
delete_bench_test.go
77 lines (61 loc) · 1.43 KB
/
delete_bench_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package sortedmap
import "testing"
func delete1ofNRecords(b *testing.B, n int) {
sm, _, keys, err := newRandSortedMapWithKeys(n)
if err != nil {
b.Fatal(err)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
sm.Delete(keys[0])
b.StopTimer()
sm, _, keys, err = newRandSortedMapWithKeys(n)
if err != nil {
b.Fatal(err)
}
b.StartTimer()
}
}
func batchDeleteNofNRecords(b *testing.B, n int) {
sm, _, keys, err := newRandSortedMapWithKeys(n)
if err != nil {
b.Fatal(err)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
sm.BatchDelete(keys)
b.StopTimer()
sm, _, keys, err = newRandSortedMapWithKeys(n)
if err != nil {
b.Fatal(err)
}
b.StartTimer()
}
}
func BenchmarkDelete1of1Records(b *testing.B) {
delete1ofNRecords(b, 1)
}
func BenchmarkDelete1of10Records(b *testing.B) {
delete1ofNRecords(b, 10)
}
func BenchmarkDelete1of100Records(b *testing.B) {
delete1ofNRecords(b, 100)
}
func BenchmarkDelete1of1000Records(b *testing.B) {
delete1ofNRecords(b, 1000)
}
func BenchmarkDelete1of10000Records(b *testing.B) {
delete1ofNRecords(b, 10000)
}
func BenchmarkBatchDelete10of10Records(b *testing.B) {
batchDeleteNofNRecords(b, 10)
}
func BenchmarkBatchDelete100of100Records(b *testing.B) {
batchDeleteNofNRecords(b, 100)
}
func BenchmarkBatchDelete1000of1000Records(b *testing.B) {
batchDeleteNofNRecords(b, 1000)
}
func BenchmarkBatchDelete10000of10000Records(b *testing.B) {
batchDeleteNofNRecords(b, 10000)
}