forked from chen3feng/skiplist-survey
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sean.go
84 lines (61 loc) · 1.38 KB
/
sean.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
78
79
80
81
82
83
84
package main
import (
"time"
seaSkiplist "github.com/sean-public/fast-skiplist"
)
func seanInserts(n int) {
list := seaSkiplist.New()
defer timeTrack(time.Now(), n)
for i := 0; i < n; i++ {
list.Set(float64(n-i), testByteString)
}
}
func seanWorstInserts(n int) {
list := seaSkiplist.New()
defer timeTrack(time.Now(), n)
for i := 0; i < n; i++ {
list.Set(float64(i), testByteString)
}
}
func seanAvgSearch(n int) {
list := seaSkiplist.New()
for i := 0; i < n; i++ {
list.Set(float64(n-i), testByteString)
}
defer timeTrack(time.Now(), n)
for i := 0; i < n; i++ {
_ = list.Get(float64(i))
}
}
func seanSearchEnd(n int) {
list := seaSkiplist.New()
for i := 0; i < n; i++ {
list.Set(float64(n-i), testByteString)
}
defer timeTrack(time.Now(), n)
for i := 0; i < n; i++ {
_ = list.Get(float64(n))
}
}
func seanDelete(n int) {
list := seaSkiplist.New()
for i := 0; i < n; i++ {
list.Set(float64(n-i), testByteString)
}
defer timeTrack(time.Now(), n)
for i := 0; i < n; i++ {
_ = list.Remove(float64(i))
}
}
func seanWorstDelete(n int) {
list := seaSkiplist.New()
for i := 0; i < n; i++ {
list.Set(float64(n-i), testByteString)
}
defer timeTrack(time.Now(), n)
for i := 0; i < n; i++ {
_ = list.Remove(float64(n - i))
}
}
var seanFunctions = []func(int){seanInserts, seanWorstInserts,
seanAvgSearch, seanSearchEnd, seanDelete, seanWorstDelete}