-
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
vegeta plot command #317
Conversation
This commit introduces timeseries downsampling in the plot reporter with the aim to be performant even with very large result sets. Fixes #137
lib/reporters.go
Outdated
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()), |
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
lib/reporters.go
Outdated
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 comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary conversion
Here's a visual representation of the effect of this change set. As for the performance effects, you can test by downloading the attached HTML files and opening each of them. BeforeAfter |
lib/plot_test.go
Outdated
// Start benchmark | ||
b.ReportAllocs() | ||
b.StartTimer() | ||
for i := 0; i < b.N; i++ { | ||
rep.Report(ioutil.Discard) | ||
NewHTMLPlot("Vegeta Plot", 5000, rs).WriteTo(ioutil.Discard) |
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.
Error return value of (github.com/tsenart/vegeta/lib.HTMLPlot).WriteTo
is not checked
ab4f5e2
to
0aa7bbf
Compare
fmt.Fprintln(os.Stderr, plotUsage) | ||
} | ||
|
||
return command{fs, func(args []string) error { |
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.
github.com/tsenart/vegeta.command composite literal uses unkeyed fields
} | ||
|
||
return command{fs, func(args []string) error { | ||
fs.Parse(args) |
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.
Error return value of fs.Parse
is not checked
0aa7bbf
to
d1de3bb
Compare
This commit introduces a new plot command that was extracted from vegeta report so that it supports specific flags. Along with it, `NewPlotReporter` has been refactored into an `HTMLPlot` that knows how to `WriteTo` an `io.Writer`.
d1de3bb
to
0d2e7f7
Compare
lib/plot_test.go
Outdated
b.ReportAllocs() | ||
b.StartTimer() | ||
for i := 0; i < b.N; i++ { | ||
NewHTMLPlot("Vegeta Plot", 5000, rs).WriteTo(ioutil.Discard) |
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.
Error return value of (github.com/tsenart/vegeta/lib.HTMLPlot).WriteTo
is not checked
4a4e7ba
to
e1a4f38
Compare
lib/plot.go
Outdated
cw := countingWriter{w: w} | ||
err = plotTemplate.Execute(&cw, &plotData{ | ||
Title: p.title, | ||
HTML2CanvasJS: template.JS(asset(html2canvas)), |
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.
G203: this method will not auto-escape HTML. Verify data is well formed.
lib/plot.go
Outdated
err = plotTemplate.Execute(&cw, &plotData{ | ||
Title: p.title, | ||
HTML2CanvasJS: template.JS(asset(html2canvas)), | ||
DygraphsJS: template.JS(asset(dygraphs)), |
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.
G203: this method will not auto-escape HTML. Verify data is well formed.
lib/plot.go
Outdated
Title: p.title, | ||
HTML2CanvasJS: template.JS(asset(html2canvas)), | ||
DygraphsJS: template.JS(asset(dygraphs)), | ||
Data: template.JS(data), |
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.
G203: this method will not auto-escape HTML. Verify data is well formed.
lib/lttb_test.go
Outdated
// From https://raw.githubusercontent.com/sveinn-steinarsson/flot-downsample/master/demo_data.js | ||
var points = [][]point{ | ||
{ | ||
{0, 29.357995947822218}, |
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.
github.com/tsenart/vegeta/lib.point composite literal uses unkeyed fields
lib/lttb_test.go
Outdated
var points = [][]point{ | ||
{ | ||
{0, 29.357995947822218}, | ||
{1, 29.40932479606209}, |
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.
github.com/tsenart/vegeta/lib.point composite literal uses unkeyed fields
lib/lttb_test.go
Outdated
{ | ||
{0, 29.357995947822218}, | ||
{1, 29.40932479606209}, | ||
{2, 29.28168582006162}, |
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.
github.com/tsenart/vegeta/lib.point composite literal uses unkeyed fields
lib/lttb_test.go
Outdated
|
||
b.Run("tsenart", func(b *testing.B) { | ||
for i := 0; i < b.N; i++ { | ||
lttb(len(data), 1000, newIterator(points[0])) |
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.
Error return value of lttb
is not checked
28b2dc3
to
b313306
Compare
b313306
to
05d47cf
Compare
This commit makes timestamps and sequence numbers maintain the exact same ordering.
|
||
b.Run("tsenart", func(b *testing.B) { | ||
for i := 0; i < b.N; i++ { | ||
Downsample(len(data), 1000, newIterator(points[0])) |
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.
Error return value of Downsample
is not checked
This PR introduces a new
vegeta plot
command that is an evolution of the previousvegeta report -reporter=plot
. Additionally, all plot related code has moved to its own package.Features
Fixes #137
TODO
Future work