-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
61 lines (47 loc) · 1.34 KB
/
main.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
package main
import (
"context"
"flag"
"fmt"
"kv_benchmark/benchmark"
_ "kv_benchmark/db/pika"
_ "kv_benchmark/db/tikv"
"kv_benchmark/kvdb"
"os"
"strings"
)
var (
dbArg = new(kvdb.DBArg)
dbName string
addrs string
threadCount uint
opCount uint
opType string
keyLen uint
valueLen uint
batchSize uint
readRatio float64
)
func initVar() {
flag.StringVar(&dbName, "db", "tikv", "db's name to test")
flag.StringVar(&addrs, "addr", "127.0.0.1:2379", "db's addrs to connect")
flag.UintVar(&dbArg.MaxConn, "max_conn", 128, "max connection to db")
flag.UintVar(&dbArg.BatchSize, "batch", 1, "batch size of request to db")
flag.UintVar(&threadCount, "tc", 1, "thread count to test")
flag.UintVar(&opCount, "oc", 1000, "operation count to test")
flag.StringVar(&opType, "ot", "w", `operation type ['r' or 'w']`)
flag.UintVar(&keyLen, "klen", 10, "the length of key")
flag.UintVar(&valueLen, "vlen", 64, "the length of value")
flag.Float64Var(&readRatio, "rr", 0.5, "read ratio of all operation")
flag.Parse()
if opCount < threadCount {
fmt.Fprintln(os.Stderr, "operation count must gte thread count")
os.Exit(-1)
}
dbArg.Addrs = strings.Split(addrs, ",")
}
func main() {
initVar()
scheduler := benchmark.NewScheduler(dbArg, dbName, threadCount, opCount, keyLen, valueLen, readRatio)
scheduler.Run(context.Background())
}