forked from armon/go-chord
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lm_bench_test.go
46 lines (42 loc) · 1.2 KB
/
lm_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
package buddystore
import (
"fmt"
"testing"
)
var i uint = 10000
/* Execute these benchmarks separately for graphing purposes */
func BenchmarkRead_NoReplica(b *testing.B) {
var listen string = fmt.Sprintf("localhost:%d", i)
i++
trans, err := InitTCPTransport(listen, timeout)
if err != nil {
fmt.Println("TCP Transport err : ", err)
}
var conf *Config = fastConf()
r, _ := Create(conf, trans)
lm := &LManagerClient{Ring: r, RLocks: make(map[string]*RLockVal), WLocks: make(map[string]*WLockVal)}
version, _ := lm.WLock(TEST_KEY, 1, 10)
_ = lm.CommitWLock(TEST_KEY, version)
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, _ = lm.RLock(TEST_KEY, true)
}
r.Shutdown()
}
func BenchmarkWriteAndCommit_NoReplica(b *testing.B) {
var listen string = fmt.Sprintf("localhost:%d", i)
i++
trans, err := InitTCPTransport(listen, timeout)
if err != nil {
fmt.Println("TCP Transport err : ", err)
}
var conf *Config = fastConf()
r, _ := Create(conf, trans)
lm := &LManagerClient{Ring: r, RLocks: make(map[string]*RLockVal), WLocks: make(map[string]*WLockVal)}
b.ResetTimer()
for i := 0; i < b.N; i++ {
version, _ := lm.WLock(TEST_KEY, uint(i+1), 10)
_ = lm.CommitWLock(TEST_KEY, version)
}
r.Shutdown()
}