-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
54 lines (43 loc) · 1.03 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
package main
import (
"time"
"github.com/Oppodelldog/bigo"
)
func main() {
const (
sleepA = 100 * time.Millisecond
factorA = 1
sleepB = 200 * time.Millisecond
factorB = 2
)
for testName, testRunner := range map[string]Runner{
"VariantA": {Sleep: sleepA, Factor: factorA},
"VariantB": {Sleep: sleepB, Factor: factorB},
} {
bigo.
New(
testName,
testRunner,
bigo.NewArrayStepper([]float64{1, 2, 3}),
).
Run().
WriteResultsToJSON().
PlotResults()
}
}
// Runner implements TestRunner.
type Runner struct {
Sleep time.Duration
Factor int
}
// Step simulated 3 additional scales to the given N. In this case.
func (r Runner) Step(n float64) bigo.OMeasures {
var measures bigo.OMeasures
for i := 1; i <= 3; i++ {
timeStart := time.Now()
// sleep is just for simulation real logic that is being measured.
time.Sleep(r.Sleep * time.Duration(n) * time.Duration(i*r.Factor))
measures = append(measures, bigo.OMeasure{O: float64(time.Since(timeStart).Milliseconds())})
}
return measures
}