summaryrefslogtreecommitdiff
path: root/benchmark/scatter.R
diff options
context:
space:
mode:
authorAndreas Madsen <amwebdk@gmail.com>2016-08-27 13:27:02 +0200
committerAndreas Madsen <amwebdk@gmail.com>2016-09-16 20:58:27 +0200
commitd3834a1fa329763062b2885391e962cb111fc44a (patch)
treec93a5af1a92453985951aab0db2c7c11a22e0676 /benchmark/scatter.R
parent6f9157fbabfb2308f362314f8fee8d0fb2d4ae8f (diff)
downloadandroid-node-v8-d3834a1fa329763062b2885391e962cb111fc44a.tar.gz
android-node-v8-d3834a1fa329763062b2885391e962cb111fc44a.tar.bz2
android-node-v8-d3834a1fa329763062b2885391e962cb111fc44a.zip
benchmark: ignore significance when using --runs 1
Because the standard deviation can't be calculated when there is only one observation the R scripts raises an error. However it may still be useful to run them for non-statistical purposes. This changes the behaviour such when there is only one observation, the values that depends on the standard deviation becomes Not Applicable (NA). Fixes: https://github.com/nodejs/node/issues/8288 PR-URL: https://github.com/nodejs/node/pull/8299 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'benchmark/scatter.R')
-rw-r--r--benchmark/scatter.R17
1 files changed, 12 insertions, 5 deletions
diff --git a/benchmark/scatter.R b/benchmark/scatter.R
index 7b98611482..10e099e430 100644
--- a/benchmark/scatter.R
+++ b/benchmark/scatter.R
@@ -51,13 +51,17 @@ if (length(aggregate) > 0) {
stats = ddply(dat, c(x.axis.name, category.name), function(subdat) {
rate = subdat$rate;
- # calculate standard error of the mean
- se = sqrt(var(rate)/length(rate));
+ # calculate confidence interval of the mean
+ ci = NA;
+ if (length(rate) > 1) {
+ se = sqrt(var(rate)/length(rate));
+ ci = se * qt(0.975, length(rate) - 1)
+ }
# calculate mean and 95 % confidence interval
r = list(
rate = mean(rate),
- confidence.interval = se * qt(0.975, length(rate) - 1)
+ confidence.interval = ci
);
return(data.frame(r));
@@ -66,11 +70,14 @@ stats = ddply(dat, c(x.axis.name, category.name), function(subdat) {
print(stats, row.names=F);
if (!is.null(plot.filename)) {
- p = ggplot(stats, aes_string(x=x.axis.name, y='mean', colour=category.name));
+ p = ggplot(stats, aes_string(x=x.axis.name, y='rate', colour=category.name));
if (use.log2) {
p = p + scale_x_continuous(trans='log2');
}
- p = p + geom_errorbar(aes(ymin=mean-confidence.interval, ymax=mean+confidence.interval), width=.1);
+ p = p + geom_errorbar(
+ aes(ymin=rate-confidence.interval, ymax=rate+confidence.interval),
+ width=.1, na.rm=TRUE
+ );
p = p + geom_point();
p = p + ylab("rate of operations (higher is better)");
p = p + ggtitle(dat[1, 1]);