Repository navigation
Expand file tree
/
Copy pathmain.go
More file actions
64 lines (56 loc) · 1.33 KB
/
Copy pathmain.go
File metadata and controls
64 lines (56 loc) · 1.33 KB
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
package main
import (
"flag"
"fmt"
"log"
"os"
"time"
zkb "github.com/OrderLab/zkbench/bench"
)
var (
conf = flag.String("conf", "bench.conf", "Benchmark configuration file")
outprefix = flag.String("outprefix", "zkresult", "Benchmark stat filename prefix")
nonstop = flag.Bool("nonstop", false, "Run the benchmarks non-stop")
purge = flag.Bool("purge", false, "Purge all prior test data")
rawstat = flag.Bool("rawstat", false, "Log the raw benchmark stats")
)
type logWriter struct {
}
func (writer logWriter) Write(bytes []byte) (int, error) {
return fmt.Print(time.Now().UTC().Format("2006-01-02T15:04:05.999Z") + string(bytes))
}
func main() {
flag.Parse()
config, err := zkb.ParseConfig(*conf)
if err != nil {
fmt.Fprintf(os.Stderr, "Fail to parse config: %v\n", err)
os.Exit(1)
}
fmt.Println(zkb.TypeStr(config.Type))
log.SetFlags(0)
log.SetOutput(new(logWriter))
b := new(zkb.Benchmark)
b.BenchConfig = *config
b.Init()
if *purge {
fmt.Println("Start purging test data")
b.Done()
fmt.Println("Done")
return
}
b.SmokeTest()
current := time.Now()
prefix := *outprefix + "-" + current.Format("2006-01-02-15_04_05") + "-"
var iter int64 = 1
for {
b.Run(prefix, *rawstat, *nonstop, iter)
if !*nonstop {
break
}
time.Sleep(30000 * time.Millisecond)
iter++
}
if b.Cleanup {
b.Done()
}
}