forked from jdeppe-pivotal/go-redis-benchmark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
73 lines (61 loc) · 1.76 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
62
63
64
65
66
67
68
69
70
71
72
73
package main
import (
"flag"
"fmt"
"rbm/benchmark"
"strings"
)
const (
ITERATIONS = 100000
HOST_PORT = "localhost:6379"
CLIENT_COUNT = 50
)
func main() {
var hostsPortsArg string
var iterations int
var clientCount int
var variant1 int
var variant2 int
var testName string
var help bool
var ignoreErrors bool
var sremAfterSadd bool
flag.StringVar(&hostsPortsArg, "h", HOST_PORT, "comma-separated host:port list")
flag.IntVar(&iterations, "i", ITERATIONS, "iterations of the test to run - divided among clients")
flag.IntVar(&clientCount, "c", CLIENT_COUNT, "number of clients to use")
flag.IntVar(&variant1, "x", 1, "variant 1 - test dependent")
flag.IntVar(&variant2, "y", 1, "variant 2 - test dependent")
flag.StringVar(&testName, "t", "sadd", "benchmark to run")
flag.BoolVar(&help, "help", false, "help")
flag.BoolVar(&ignoreErrors, "ignore-errors", false, "ignore errors from Redis calls")
flag.BoolVar(&sremAfterSadd, "srem-after-sadd", false, "delete entries immediately after creation")
flag.Parse()
if help {
flag.Usage()
}
hostsPorts := strings.Split(hostsPortsArg, ",")
clientIterations := iterations / clientCount
testConfig := &benchmark.TestConfig{
HostPort: hostsPorts,
ClientCount: clientCount,
Iterations: iterations,
ClientIterations: clientIterations,
Variant1: variant1,
Variant2: variant2,
IgnoreErrors: ignoreErrors,
SremAfterSadd: sremAfterSadd,
}
var benchmarker benchmark.Runner
switch testName {
case "sadd":
benchmarker = benchmark.NewSaddBenchmark(testConfig)
break
case "pubsub":
benchmarker = benchmark.NewPubSubBenchmark(testConfig)
break
default:
panic(fmt.Sprintf("unknown test: %s", testName))
}
//benchmarker.Execute()
benchmarker.Launch()
}