Make Results private
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -24,5 +24,5 @@ _testmain.go
|
||||
vegeta
|
||||
vegeta.test
|
||||
targets.txt
|
||||
|
||||
vegeta-*.tar.gz
|
||||
lib/lib.test
|
||||
|
||||
@@ -8,6 +8,17 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Result represents the metrics defined out of an http.Response
|
||||
// generated by each target hit
|
||||
type Result struct {
|
||||
Code uint16
|
||||
Timestamp time.Time
|
||||
Timing time.Duration
|
||||
BytesOut uint64
|
||||
BytesIn uint64
|
||||
Error error
|
||||
}
|
||||
|
||||
// Attack hits the passed Targets (http.Requests) at the rate specified for
|
||||
// duration time and then waits for all the requests to come back.
|
||||
// The results of the attack are put into a slice which is returned.
|
||||
@@ -15,7 +26,7 @@ func Attack(targets Targets, rate uint64, duration time.Duration) []Result {
|
||||
total := rate * uint64(duration.Seconds())
|
||||
hits := make(chan *http.Request, total)
|
||||
res := make(chan Result, total)
|
||||
results := make(Results, total)
|
||||
results := make(results, total)
|
||||
// Scatter
|
||||
go drill(rate, hits, res)
|
||||
for i := 0; i < cap(hits); i++ {
|
||||
@@ -33,22 +44,12 @@ func Attack(targets Targets, rate uint64, duration time.Duration) []Result {
|
||||
return results
|
||||
}
|
||||
|
||||
// Result represents the metrics we want out of an http.Response
|
||||
type Result struct {
|
||||
Code uint16
|
||||
Timestamp time.Time
|
||||
Timing time.Duration
|
||||
BytesOut uint64
|
||||
BytesIn uint64
|
||||
Error error
|
||||
}
|
||||
// results is a slice of Result defined only to be sortable with sort.Interface
|
||||
type results []Result
|
||||
|
||||
// Results is a slice of Result defined only to be sortable with sort.Interface
|
||||
type Results []Result
|
||||
|
||||
func (r Results) Len() int { return len(r) }
|
||||
func (r Results) Less(i, j int) bool { return r[i].Timestamp.Before(r[j].Timestamp) }
|
||||
func (r Results) Swap(i, j int) { r[i], r[j] = r[j], r[i] }
|
||||
func (r results) Len() int { return len(r) }
|
||||
func (r results) Less(i, j int) bool { return r[i].Timestamp.Before(r[j].Timestamp) }
|
||||
func (r results) Swap(i, j int) { r[i], r[j] = r[j], r[i] }
|
||||
|
||||
// drill loops over the passed reqs channel and executes each request.
|
||||
// It is throttled to the rate specified.
|
||||
|
||||
Reference in New Issue
Block a user