forked from PRL-PRG/trustworthy-titanic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtitanicRunner.R
50 lines (44 loc) · 1.29 KB
/
titanicRunner.R
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
# Listing packages
packages <- installed.packages()
# Loading packages]
lapply(packages, require, character.only = TRUE)
#-------------get function calls
for (dir in dirs)
{
try(
{
print(dir)
d = paste("~/titanic/notebooksnotebooks/r/kernels/",dir, sep="")
d = paste(d, "/script", sep="")
print(d)
setwd(d)
f.name <- list.files(path = ".", pattern = "\\.R$", full.names = TRUE, recursive = TRUE, ignore.case = TRUE)
print(f.name)
lst <- list.functions.in.file(f.name, alphabetic = TRUE)
exportJSON <- toJSON(lst)
write(exportJSON, paste(str_remove(f.name, ".R"), ".json", sep=""))
}
)
}
#----------get runtimes
names = c()
for (dir in dirs)
try(
{
print(dir)
d = paste("~~/titanic/notebooks/r/kernels/",dir, sep="")
d = paste(d, "/script", sep="")
setwd(d)
f.name <- list.files(path = ".", pattern = "\\.R$", full.names = TRUE, recursive = TRUE, ignore.case = TRUE)
start_time <- Sys.time()
rcmd("BATCH", f.name, timeout = 300)
end_time <- Sys.time()
t = end_time - start_time;
t = as.numeric(t, units = "secs")
print(t)
n = cbind(dir, t)
names = rbind(names, n)
}
)
setwd("~/~/titanic/notebooks")
write.csv(names, file ="timesDirs.csv", row.names=F)