-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vegeta plot command #317
Merged
Merged
vegeta plot command #317
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
c8e7de8
report: Downsample time series in plot reporter
tsenart 40f7924
vendor: Add github.com/dgryski/go-lttb
tsenart cf9f116
reporters: Elide unecessary type conversions
tsenart 435185e
reporters: Fix incorrect allocation optimisation
tsenart 0d2e7f7
plot: Introduce vegeta plot command
tsenart e1a4f38
plot: Highcharts and streaming refactoring WIP
tsenart d21bc64
git: Add *.gob and *.lz to .gitignore
tsenart f9995df
plot: Revert back to Dygraphs
tsenart 15bec40
lttb: Implement on-line version of the LTTB algorithm
tsenart 05d47cf
lttb: Fix LTTB bucketing and add better tests
tsenart 4be48a3
lttb: Move to independent package
tsenart b274d1f
attack: Same order of timestamps and seq numbers
tsenart bcddd8a
plot: Buffering logic
tsenart 6b1a62d
lttb: Checkin
tsenart cbb1581
lttb: Improve Iter comment
tsenart f3fb801
plot: Rename attackSeries to labeledSeries
tsenart eacb7a8
plot: Ensure timestamp monotonicity
tsenart f63b43a
plot: HTMLPlotOpts
tsenart c9b9ae4
plot: Move to independent package
tsenart 48ba0db
plot: Rename BenchmarkHTMLPlot
tsenart df544bc
plot: TestLabeledSeries
tsenart 24703ba
plot: Golden test for plot output
tsenart ca99fe5
plot: Update Dygraphs and HTML2Canvas
tsenart e19fc14
plot: Use github.com/tsenart/go-tsz
tsenart 0992b8e
Update .gitignore
tsenart 449e551
targets: Simplify generation code
tsenart 8a24986
plot: Update README and add examples
tsenart 52b6595
plot: Improve TestLabeledSeries
tsenart 0754549
README: Update Plot image url
tsenart b294ddb
plot: Update golden file
tsenart dd2ea0d
plot: Deterministic WriteTo output
tsenart 65989a8
Merge branch 'master' into plot-reporter-downsampling
tsenart 055ddc6
plot: Add missing assets
tsenart 9388665
Update deps
tsenart File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,12 @@ import ( | |
"encoding/json" | ||
"fmt" | ||
"io" | ||
"sort" | ||
"strconv" | ||
"strings" | ||
"text/tabwriter" | ||
|
||
lttb "github.com/dgryski/go-lttb" | ||
"github.com/lucasb-eyer/go-colorful" | ||
) | ||
|
||
|
@@ -109,51 +111,70 @@ func NewJSONReporter(m *Metrics) Reporter { | |
// http://dygraphs.com/ | ||
func NewPlotReporter(title string, rs *Results) Reporter { | ||
return func(w io.Writer) (err error) { | ||
_, err = fmt.Fprintf(w, plotsTemplateHead, title, asset(dygraphs), asset(html2canvas)) | ||
if err != nil { | ||
return err | ||
series := make(map[string][]Results, len(*rs)) | ||
for _, r := range *rs { | ||
idx := 0 | ||
if r.Error == "" { | ||
idx++ | ||
} | ||
|
||
if len(series[r.Attack]) == 0 { | ||
series[r.Attack] = make([]Results, 2) | ||
} | ||
|
||
series[r.Attack][idx] = append(series[r.Attack][idx], r) | ||
} | ||
|
||
attacks := make(map[string]Results, len(*rs)) | ||
for _, r := range *rs { | ||
attacks[r.Attack] = append(attacks[r.Attack], r) | ||
samples := make(map[string][][]lttb.Point, len(series)) | ||
for attack, results := range series { | ||
for i := range results { | ||
sort.Sort(results[i]) | ||
points := make([]lttb.Point, 0, len(results[i])) | ||
for _, r := range results[i] { | ||
points = append(points, lttb.Point{ | ||
X: float64(r.Timestamp.Sub(results[i][0].Timestamp).Seconds()), | ||
Y: float64(r.Latency.Seconds() * 1000), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unnecessary conversion |
||
}) | ||
} | ||
samples[attack] = append(samples[attack], lttb.LTTB(points, 1000)) | ||
} | ||
} | ||
|
||
const series = 2 // OK and Errors | ||
i, offsets := 0, make(map[string]int, len(attacks)) | ||
for attack := range attacks { | ||
offsets[attack] = 1 + i*series | ||
const count = 2 // OK and Errors | ||
i, offsets := 0, make(map[string]int, len(series)) | ||
for name := range series { | ||
offsets[name] = 1 + i*count | ||
i++ | ||
} | ||
|
||
const nan = "NaN" | ||
|
||
data := make([]string, 1+len(attacks)*series) | ||
for attack, results := range attacks { | ||
for i, r := range results { | ||
for j := range data { | ||
data[j] = nan | ||
} | ||
_, err = fmt.Fprintf(w, plotsTemplateHead, title, asset(dygraphs), asset(html2canvas)) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
offset := offsets[attack] | ||
if r.Error == "" { | ||
offset++ | ||
} | ||
const nan = "NaN" | ||
|
||
ts := r.Timestamp.Sub(results[0].Timestamp).Seconds() | ||
data[0] = strconv.FormatFloat(ts, 'f', -1, 32) | ||
data := make([]string, 1+len(series)*count) | ||
for attack, results := range samples { | ||
for idx, points := range results { | ||
for i, p := range points { | ||
for j := range data { | ||
data[j] = nan | ||
} | ||
|
||
latency := r.Latency.Seconds() * 1000 | ||
data[offset] = strconv.FormatFloat(latency, 'f', -1, 32) | ||
offset := offsets[attack] + idx | ||
data[0] = strconv.FormatFloat(p.X, 'f', -1, 32) | ||
data[offset] = strconv.FormatFloat(p.Y, 'f', -1, 32) | ||
|
||
s := "[" + strings.Join(data, ",") + "]" | ||
s := "[" + strings.Join(data, ",") + "]" | ||
|
||
if i < len(*rs)-1 { | ||
s += "," | ||
} | ||
if i < len(*rs)-1 { | ||
s += "," | ||
} | ||
|
||
if _, err = io.WriteString(w, s); err != nil { | ||
return err | ||
if _, err = io.WriteString(w, s); err != nil { | ||
return err | ||
} | ||
} | ||
} | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary conversion