forked from myzhan/boomer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
standalone.go
36 lines (28 loc) · 831 Bytes
/
standalone.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
package main
import (
"log"
"time"
"github.com/naturezhm/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)
globalBoomer.RecordSuccess("http", "foo", elapsed.Nanoseconds()/int64(time.Millisecond), int64(10))
}
var globalBoomer *boomer.Boomer
func main() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
task1 := &boomer.Task{
Name: "foo",
Weight: 10,
Fn: foo,
}
numClients := 10
spawnRate := float64(10)
globalBoomer = boomer.NewStandaloneBoomer(numClients, spawnRate)
globalBoomer.AddOutput(boomer.NewConsoleOutput())
globalBoomer.Run(task1)
}