Skip to content

Commit 4301ebd

Browse files
authored
Rollup merge of rust-lang#61839 - alexcrichton:pr-and-master-builds, r=pietroalbini
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. Some example graphs from the [latest build](https://dev.azure.com/rust-lang/rust/_build/results?buildId=717) look like: ![dist-x86_64-apple](https://user-images.githubusercontent.com/64996/59520676-16c5b000-8e90-11e9-9188-27001911f270.png) ![x86_64-msvc-1](https://user-images.githubusercontent.com/64996/59520677-175e4680-8e90-11e9-8568-4b564807324e.png) ![x86_64-mingw-1](https://user-images.githubusercontent.com/64996/59520680-175e4680-8e90-11e9-939d-a73c7224582f.png) ![test-various](https://user-images.githubusercontent.com/64996/59520682-175e4680-8e90-11e9-9980-900ed4eeb8f4.png)
2 parents 32254ac + 831ddf7 commit 4301ebd

File tree

2 files changed

+51
-17
lines changed

2 files changed

+51
-17
lines changed

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

Lines changed: 2 additions & 17 deletions
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

Lines changed: 49 additions & 0 deletions
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)