-
Notifications
You must be signed in to change notification settings - Fork 9
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
k6 v0.42.0 updates - helper scripts (3/5) #23
Conversation
This ensures a more accurate reading and output.
To ensure it outputs 0 in case the PID is not found.
rpsf=$(mktemp) | ||
|
||
cleanup() { | ||
rm -f "$cpuf" "$memf" "$vusf" "$rpsf" |
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.
In general I prefer to wrap variables in quotes and in ${}
not only prefix them with $
.
IIRC that also prevents you from potentially matching a shorter variable that is just prefix of the longer one.
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.
Right, I do that as well where it's useful (e.g. part of an interpolated string), but in this case there's no reason to do so, since they're separate arguments, and there's no risk of mistakenly using a different variable.
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.
LGTM but I would prefer to get the bash variables wrapped in quotes and in ${}
This is PR 3/5, part of updating the "Running large tests" article and running benchmarks on k6 v0.42.0.
These changes add a couple of helper scripts:
k6bench.sh
: runs k6 in the background, while collecting performance metrics (CPU/RAM usage of the k6 process,vus
andhttp_reqs
metrics from the k6 HTTP API), and writing them to stdout in CSV format.The polling period is configurable with the
K6_BENCH_SAMPLE_INTERVAL
env var, and defaults to 5s.Example command:
k6bench.gnuplot
: a gnuplot 5.4 script to generate graphs from the CSV output from thek6bench.sh
script.Example command:
gnuplot -e 'k6version="v0.42.0"; ec2instance="m5.large"; script="website.js-10s"' ../../k6bench.gnuplot
m5.large-website.js-10s.png
in the current directory.More command examples and outputs of these scripts can be seen in #24.
The idea is that these scripts will be run in CI and the entire benchmarking process will be automated. I didn't want to rely on k6 Cloud for metric aggregation and graphing for several reasons:
--out cloud
consumes considerable network bandwidth, which could affect some of the network tests, CPU usage or even RPS.I'm open to any improvement suggestions to this process, but so far I think it's the best approach.
PR order: #21 -> #22 -> #23 -> #24 -> #25 (review and merge in reverse)