forked from basho/basho_bench
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.r
More file actions
48 lines (39 loc) · 1.62 KB
/
common.r
File metadata and controls
48 lines (39 loc) · 1.62 KB
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
# Load all the necessary packages, installing missing ones when necessary
packages.to.install <- c("plyr", "grid", "getopt", "proto", "ggplot2")
for(p in packages.to.install)
{
print(p)
if (suppressWarnings(!require(p, character.only = TRUE))) {
install.packages(p, repos = "http://lib.stat.cmu.edu/R/CRAN")
library(p, character.only=TRUE)
}
}
# Load a latency file and ensure that it is appropriately tagged
load_latency_frame <- function(File)
{
op <- gsub("_latencies.csv", "", basename(File))
frame <- read.csv(File)
frame$op = rep(op, nrow(frame))
return (frame)
}
# Load summary and latency information for a given directory
load_benchmark <- function(Dir, Tstart, Tend)
{
## Load up summary data
summary <- read.csv(sprintf("%s/%s", Dir, "summary.csv"),
colClasses=rep("numeric", 5))
## Get a list of latency files
latencies <- lapply(list.files(path = Dir, pattern = "_latencies.csv",
full.names = TRUE),
load_latency_frame)
latencies <- do.call('rbind', latencies)
## Convert timing information in latencies from usecs -> msecs
latencies[4:10] <- latencies[4:10] / 1000
## Trim values off that are outside our range of times
if (is.null(Tstart)) { Tstart = 0 }
if (is.null(Tend)) { Tend = max(summary$elapsed) }
print(Tstart)
print(Tend)
return (list(summary = summary[summary$elapsed >= Tstart & summary$elapsed <= Tend,],
latencies = latencies[latencies$elapsed >= Tstart & latencies$elapsed <= Tend,]))
}