Skip to content

Commit 831ddf7

Browse files
committed
ci: Add a script for generating CPU usage graphs
This commit checks in a script which generates CPU usage graphs over time, expanding on the previous comment that was include in the collection file.
1 parent e699ea0 commit 831ddf7

File tree

2 files changed

+51
-17
lines changed

2 files changed

+51
-17
lines changed

src/ci/cpu-usage-over-time.py

+2-17
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,8 @@
3030
# the second column is always zero.
3131
#
3232
# Once you've downloaded a file there's various ways to plot it and visualize
33-
# it. For command line usage you can use a script like so:
34-
#
35-
# set timefmt '%Y-%m-%dT%H:%M:%S'
36-
# set xdata time
37-
# set ylabel "Idle CPU %"
38-
# set xlabel "Time"
39-
# set datafile sep ','
40-
# set term png
41-
# set output "printme.png"
42-
# set grid
43-
# builder = "i686-apple"
44-
# plot "cpu-".builder.".csv" using 1:2 with lines title builder
45-
#
46-
# Executed as `gnuplot < ./foo.plot` it will generate a graph called
47-
# `printme.png` which you can then open up. If you know how to improve this
48-
# script or the viewing process that would be much appreciated :) (or even if
49-
# you know how to automate it!)
33+
# it. For command line usage you use the `src/etc/cpu-usage-over-time-plot.sh`
34+
# script in this repository.
5035

5136
import datetime
5237
import sys

src/etc/cpu-usage-over-time-plot.sh

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
3+
# A small script to help visualizing CPU usage over time data collected on CI
4+
# using `gnuplot`.
5+
#
6+
# This script is expected to be called with two arguments. The first is the full
7+
# commit SHA of the build you're interested in, and the second is the name of
8+
# the builder. For example:
9+
#
10+
# ./src/etc/cpu-usage-over-time-plot.sh e699ea096fcc2fc9ce8e8bcf884e11496a31cc9f i686-mingw-1
11+
#
12+
# That will generate `$builder.png` in the current directory which you can open
13+
# up to see a hopefully pretty graph.
14+
#
15+
# Improvements to this script are greatly appreciated!
16+
17+
set -ex
18+
19+
bucket=rust-lang-ci-evalazure
20+
commit=$1
21+
builder=$2
22+
23+
curl -O https://$bucket.s3.amazonaws.com/rustc-builds/$commit/cpu-$builder.csv
24+
25+
gnuplot <<-EOF
26+
reset
27+
set timefmt '%Y-%m-%dT%H:%M:%S'
28+
set xdata time
29+
set ylabel "CPU Usage %"
30+
set xlabel "Time"
31+
set datafile sep ','
32+
set term png size 3000,1000
33+
set output "$builder.png"
34+
set grid
35+
36+
f(x) = mean_y
37+
fit f(x) 'cpu-$builder.csv' using 1:(100-\$2) via mean_y
38+
39+
set label 1 gprintf("Average = %g%%", mean_y) center font ",18"
40+
set label 1 at graph 0.50, 0.25
41+
set xtics rotate by 45 offset -2,-2.4 300
42+
set ytics 10
43+
set boxwidth 0.5
44+
45+
plot \\
46+
mean_y with lines linetype 1 linecolor rgb "#ff0000" title "average", \\
47+
"cpu-$builder.csv" using 1:(100-\$2) with points pointtype 7 pointsize 0.4 title "$builder", \\
48+
"" using 1:(100-\$2) smooth bezier linewidth 3 title "bezier"
49+
EOF

0 commit comments

Comments
 (0)