-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
75 lines (63 loc) · 2.07 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
74
75
package main
import (
"bufio"
"flag"
"github.com/RediSearch/ftsb/benchmark_runner"
)
// Program option vars:
var (
host string
password string
debug int
loader *benchmark_runner.BenchmarkRunner
pipeline int
clusterMode bool
continueOnErr bool
)
// Parse args:
func init() {
loader = benchmark_runner.GetBenchmarkRunnerWithBatchSize(10)
flag.StringVar(&host, "host", "localhost:6379", "The host:port for Redis connection")
flag.StringVar(&password, "a", "", "Password for Redis Auth.")
flag.IntVar(&debug, "debug", 0, "Debug printing (choices: 0, 1, 2). (default 0)")
flag.BoolVar(&continueOnErr, "continue-on-error", false, "If set to true, it will continue the benchmark and print the error message to stderr.")
flag.BoolVar(&clusterMode, "cluster-mode", false, "If set to true, it will run the client in cluster mode.")
flag.IntVar(&pipeline, "pipeline", 1, "Pipeline <numreq> requests. Default 1 (no pipeline).")
flag.Parse()
}
type benchmark struct {
}
func (b *benchmark) GetConfigurationParametersMap() map[string]interface{} {
configs := map[string]interface{}{}
configs["host"] = host
configs["clusterMode"] = clusterMode
configs["continueOnError"] = continueOnErr
configs["debug"] = debug
configs["pipeline"] = pipeline
return configs
}
type RedisIndexer struct {
partitions uint
}
func (i *RedisIndexer) GetIndex(itemsRead uint64, p *benchmark_runner.DocHolder) int {
return int(uint(itemsRead) % i.partitions)
}
func (b *benchmark) GetCmdDecoder(br *bufio.Reader) benchmark_runner.DocDecoder {
scanner := bufio.NewScanner(br)
buf := make([]byte, 0, 64*1024)
scanner.Buffer(buf, 1024*1024)
return &decoder{scanner: scanner}
}
func (b *benchmark) GetBatchFactory() benchmark_runner.BatchFactory {
return &factory{}
}
func (b *benchmark) GetCommandIndexer(maxPartitions uint) benchmark_runner.DocIndexer {
return &RedisIndexer{partitions: maxPartitions}
}
func (b *benchmark) GetProcessor() benchmark_runner.Processor {
return &processor{}
}
func main() {
b := benchmark{}
loader.RunBenchmark(&b, benchmark_runner.SingleQueue)
}