-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgraph
executable file
·52 lines (41 loc) · 1.47 KB
/
graph
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
set -euo pipefail
function main()
{
exec 5>&1
local output=$1
local csv="tool;steps;mean;stddev"
for crate in diesel elephantry libpq postgres sqlx
do
cd "$crate"
local bench=$(cargo bench | tee >(cat - >&5))
csv="$csv\n$(echo "$bench" | sed -E 's/test ([^ ]+) +... bench: +([0-9,\.]+) ns\/iter \(\+\/- ([0-9,\.]+)\)/'$crate';\1;\2;\3/;t;d' | sed 's/,//g')"
cd -
done
local r_script='
error.bar <- function (x, y, upper, lower=upper, length=0.1, ...) {
if (length(x) != length(y)
| length(y) !=length(lower)
| length(lower) != length(upper)
) {
stop("vectors must be same length")
}
arrows(x, y + upper, x, y - lower, angle = 90, code = 3, length = length, ...)
}
args <- commandArgs(trailingOnly = TRUE)
output <- args[1]
title <- "Rust SQL client benchmark"
png(output)
bench <- read.csv(text="'"$csv"'", header=TRUE, sep=";")
tools <- unique(bench$tool)
steps <- unique(bench$step)
mean <- t(array(bench$mean, dim=c(length(steps), length(tools)), dimnames=list(steps, tools)))
stddev <- t(array(bench$stddev, dim=c(length(steps), length(tools)), dimnames=list(steps, tools)))
op <- par(mar=c(6, 4, 4, 2))
graph <- barplot(mean, legend=tools, beside = TRUE, ylab="Duration (ns)",
ylim=c(0, max(mean) + max(stddev)), main = title,
col = rainbow(length(tools)), las = 2)
error.bar(graph, mean, stddev)'
echo "$r_script" | R --slave --args "$output" 2> /dev/null
}
main $*