Skip to content

Commit

Permalink
fix : frequency and duration to struct
Browse files Browse the repository at this point in the history
  • Loading branch information
seipan committed Aug 12, 2023
1 parent 071a5cb commit b70b128
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions vegeta.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
type Attacker struct {
path Path
methodIndex int
frequency int
duration time.Duration
}

func (atk *Attacker) Attack() {
Expand All @@ -19,16 +21,15 @@ func (atk *Attacker) Attack() {
URL: atk.path.path,
}
targeter := vegeta.NewStaticTargeter(target)
rate := vegeta.Rate{Freq: 100, Per: time.Second}
duration := 10 * time.Second
rate := vegeta.Rate{Freq: atk.frequency, Per: time.Second}

attacker := vegeta.NewAttacker()

var metrics vegeta.Metrics
var results vegeta.Results
reporter := vegeta.NewJSONReporter(&metrics)

for res := range attacker.Attack(targeter, rate, duration, "Vegeta Load Testing") {
for res := range attacker.Attack(targeter, rate, atk.duration, "Vegeta Load Testing") {
results.Add(res)
}
results.Close()
Expand Down

0 comments on commit b70b128

Please sign in to comment.