Skip to content

Instantly share code, notes, and snippets.

@AndreasMadsen
Last active August 17, 2016 20:16
Show Gist options
  • Save AndreasMadsen/4e134b478edd082e929f080d7f217be2 to your computer and use it in GitHub Desktop.
Save AndreasMadsen/4e134b478edd082e929f080d7f217be2 to your computer and use it in GitHub Desktop.
http/simple.js benchmark
filename c chunks length type rate time
http/simple.js 500 0 1024 buffer 12561.08 10.070019665
http/simple.js 500 0 1024 buffer 12295.47 10.067049961
http/simple.js 500 0 1024 buffer 12358.86 10.116325268
http/simple.js 500 0 1024 buffer 12293.9 10.064770704
http/simple.js 500 0 1024 buffer 12272.14 10.07143516
http/simple.js 500 0 1024 buffer 12453.61 10.070998224
http/simple.js 500 0 1024 buffer 12703.56 10.069003942
http/simple.js 500 0 1024 buffer 12522.2 10.066801084
http/simple.js 500 0 1024 buffer 12406.31 10.07158091
http/simple.js 500 0 1024 buffer 12214.44 10.070203855
http/simple.js 500 0 1024 buffer 12428.18 10.066255092
http/simple.js 500 0 1024 buffer 12418.06 10.076269499
http/simple.js 500 0 1024 buffer 12463.19 10.066664844
http/simple.js 500 0 1024 buffer 12162.14 10.07658183
http/simple.js 500 0 1024 buffer 12140.63 10.066435642
http/simple.js 500 0 1024 buffer 12315.7 10.144939605
http/simple.js 500 0 1024 buffer 12182.89 10.068392349
http/simple.js 500 0 1024 buffer 12374.73 10.069598296
http/simple.js 500 0 1024 buffer 12463.26 10.063785214
http/simple.js 500 0 1024 buffer 12637.24 10.063192484
http/simple.js 500 0 1024 buffer 12561.22 10.070205333
http/simple.js 500 0 1024 buffer 12537.44 10.06900589
http/simple.js 500 0 1024 buffer 11897.01 10.073472438
http/simple.js 500 0 1024 buffer 12740.29 10.062457981
http/simple.js 500 0 1024 buffer 12212.03 10.068543822
http/simple.js 500 0 1024 buffer 12487.51 10.070154202
http/simple.js 500 0 1024 buffer 12486 10.069414374
http/simple.js 500 0 1024 buffer 12476.81 10.065732614
http/simple.js 500 0 1024 buffer 11844.81 10.066512998
http/simple.js 500 0 1024 buffer 12363.5 10.062400152
#!/usr/bin/env Rscript
library(ggplot2);
library(plyr);
# get __dirname and load ./_cli.R
args = commandArgs(trailingOnly = F);
dirname = dirname(sub("--file=", "", args[grep("--file", args)]));
source(paste0(dirname, '/_cli.R'), chdir=T);
if (!is.null(args.options$help)) {
stop("usage: cat file.csv | Rscript stats.R");
}
# parse data
dat = read.csv(file('stdin'), strip.white=TRUE);
dat = data.frame(dat);
# List of aggregated variables
parameters = names(dat);
parameters = parameters[
! parameters %in% c('rate', 'time', 'filename')
];
# Calculate statistics
stats = ddply(dat, parameters, function(subdat) {
rate = subdat$rate;
n = length(rate);
se = sqrt(var(rate)/n);
cv = sd(rate) / mean(rate);
r = list(
mean = mean(rate),
std.dev = sd(rate),
cv.biased = cv,
cv.unbiased = (1 + 1/(4 * n)) * cv,
conf.int = se * qt(0.975, length(rate) - 1)
);
return(data.frame(r));
});
print(stats, row.names=F);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment