forked from myzhan/boomer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
46 lines (36 loc) · 1.09 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
package main
import (
"log"
"time"
"github.com/myzhan/boomer"
)
func foo() {
start := time.Now()
time.Sleep(100 * time.Millisecond)
elapsed := time.Since(start)
// Report your test result as a success, if you write it in python, it will looks like this
// events.request_success.fire(request_type="http", name="foo", response_time=100, response_length=10)
boomer.RecordSuccess("http", "foo", elapsed.Nanoseconds()/int64(time.Millisecond), int64(10))
}
func bar() {
start := time.Now()
time.Sleep(100 * time.Millisecond)
elapsed := time.Since(start)
// Report your test result as a failure, if you write it in python, it will looks like this
// events.request_failure.fire(request_type="udp", name="bar", response_time=100, exception=Exception("udp error"))
boomer.RecordFailure("udp", "bar", elapsed.Nanoseconds()/int64(time.Millisecond), "udp error")
}
func main() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
task1 := &boomer.Task{
Name: "foo",
Weight: 10,
Fn: foo,
}
task2 := &boomer.Task{
Name: "bar",
Weight: 30,
Fn: bar,
}
boomer.Run(task1, task2)
}