-
Notifications
You must be signed in to change notification settings - Fork 1
/
Benchmarks.go
71 lines (64 loc) · 1.44 KB
/
Benchmarks.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
package main
import (
antidote "github.com/AntidoteDB/antidote-go-client"
)
type Benchmark struct {
function func(client *antidote.Client, objects *BObject) error
init func(client *antidote.Client, objects *BObject) error
read bool
write bool
}
var Benchmarks = map[string]Benchmark{
"staticWrite": {
function: staticWrite,
init: nil,
read: false,
write: true,
},
"staticRead": {
function: staticRead,
init: initRead,
read: true,
write: false,
},
"interactiveReadWrite": {
function: interactiveReadWrite,
init: initRead,
read: true,
write: true,
},
}
func staticWrite(client *antidote.Client, objects *BObject) error {
tx := client.CreateStaticTransaction()
return tx.Update(objects.updates...)
}
func staticRead(client *antidote.Client, objects *BObject) error {
tx := client.CreateStaticTransaction()
_, err := tx.Read(objects.reads...)
return err
}
func interactiveReadWrite(client *antidote.Client, objects *BObject) error {
tx, err := client.StartTransaction()
if err != nil {
return err
}
_, err = tx.Read(objects.reads...)
if err != nil {
return err
}
err = tx.Update(objects.updates...)
if err != nil {
return err
}
return tx.Commit()
}
func initRead(client *antidote.Client, objects *BObject) error {
tx := client.CreateStaticTransaction()
for _, update := range objects.updates {
err := tx.Update(update)
if err != nil {
return err
}
}
return nil
}