1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
#!/bin/bash
#
# Run Criterion Benchmarks
#
# enable bench-only dependencies in Cargo
sed -i.bak -e 's/# BENCH: //' Cargo.toml
# Run criterion
cargo bench "$@"
# Restore Cargo.toml with backup
mv Cargo.toml.bak Cargo.toml
# store extra things for the benchmarking report
if [ -n "$BENCHMARK_EXTRAS" ]; then
cat <<EOF > index.html
<!doctype html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<title>BigDecimal Benchmark Results</title>
<style>
a:link { color: #06C; }
img.probability-distribution-function { max-width:1200px; display:block; margin:1em auto; }
a.sample-json { max-width:1400px; display:block; margin:0 auto; }
</style>
</head>
<small style='color:#AAA; float:right'>${CI_COMMIT_SHA}</small>
<h1>BigDecimal Benchmark Results</h1>
<p><b>Criterion Report:</b> <a href='target/criterion/report/'>Report</a></p>
EOF
# Add svg plots to index html
find target/criterion -name 'pdf.svg' -type f -print0 |
sort -z |
while read -r -d $'\0' svg_file
do
name=$(echo "$svg_file" | cut -d '/' -f 3)
sample_datafile=target/criterion/$name/new/sample.json
if [ -f "$sample_datafile" ]; then
echo "<p><a href='${sample_datafile}' class='sample-json'>$name</a>" >> index.html
else
echo "<p>$name</p>" >> index.html
fi
echo "<a href='${svg_file}'><img src='${svg_file}' class='probability-distribution-function'></a>" >> index.html
done
fi
|