Skip to content

Commit

Permalink
dir change
Browse files Browse the repository at this point in the history
  • Loading branch information
seipan committed Aug 12, 2023
1 parent 0e00664 commit 361ab0c
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 32 deletions.
1 change: 0 additions & 1 deletion api.go

This file was deleted.

1 change: 0 additions & 1 deletion api_test.go

This file was deleted.

35 changes: 35 additions & 0 deletions attack.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package bluma

import (
"fmt"
"os"
"time"

vegeta "github.com/tsenart/vegeta/lib"
)

func (atk *Attacker) Attack() {
target := vegeta.Target{
Method: atk.path.method[atk.methodIndex].method,
URL: atk.path.path,
Body: atk.body,
Header: atk.header,
}
targeter := vegeta.NewStaticTargeter(target)
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, atk.duration, "Vegeta Load Testing") {
results.Add(res)
}
results.Close()
reporter.Report(os.Stdout)

fmt.Printf("Mean response time: %s\n", metrics.Latencies.Mean)
fmt.Printf("99th percentile response time: %s\n", metrics.Latencies.P99)
}
File renamed without changes.
30 changes: 0 additions & 30 deletions vegeta.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package bluma

import (
"fmt"
"net/http"
"os"
"time"

vegeta "github.com/tsenart/vegeta/lib"
)

type Attacker struct {
Expand All @@ -17,29 +13,3 @@ type Attacker struct {
frequency int
duration time.Duration
}

func (atk *Attacker) Attack() {
target := vegeta.Target{
Method: atk.path.method[atk.methodIndex].method,
URL: atk.path.path,
Body: atk.body,
Header: atk.header,
}
targeter := vegeta.NewStaticTargeter(target)
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, atk.duration, "Vegeta Load Testing") {
results.Add(res)
}
results.Close()
reporter.Report(os.Stdout)

fmt.Printf("Mean response time: %s\n", metrics.Latencies.Mean)
fmt.Printf("99th percentile response time: %s\n", metrics.Latencies.P99)
}

0 comments on commit 361ab0c

Please sign in to comment.