-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
37 lines (32 loc) · 879 Bytes
/
main.go
File metadata and controls
37 lines (32 loc) · 879 Bytes
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
package main
import (
"fmt"
"io/ioutil"
"time"
vegeta "github.com/tsenart/vegeta/lib"
)
func main() {
rate := uint64(250) // per second
duration := 4 * time.Second
body, err := ioutil.ReadFile("reqBody.json")
if err != nil {
fmt.Println("err:", err)
return
}
//fmt.Println("body:", string(body))
targeter := vegeta.NewStaticTargeter(vegeta.Target{
Method: "POST",
URL: "http://localhost:8090/alerting/v1/partners/123/sites/23/alerts",
Body: body,
})
attacker := vegeta.NewAttacker()
var metrics vegeta.Metrics
for res := range attacker.Attack(targeter, rate, duration) {
metrics.Add(res)
}
metrics.Close()
fmt.Printf("99th percentile: %s\n", metrics.Latencies.P99)
fmt.Printf("max: %s\n", metrics.Latencies.Max)
fmt.Println("total no of request executed:", metrics.Requests)
fmt.Println("per of non error response:", metrics.Success)
}