|
1 | | -benchmark.data.table = function(script="benchmarks.Rraw", rbin="Rscript", desc=character()) { |
| 1 | +benchmark.data.table = function(script="benchmarks.Rraw", rbin="Rscript", desc=character(), libs=NULL) { |
2 | 2 | stopifnot(length(script)==1L) |
3 | | - # make revision && make build && make install && R -q -e 'data.table:::benchmark.data.table()' |
4 | | - fn = setNames(file.path("inst","benchmarks", script), script) ## this path only for development, finally use system.file(package="data.table", "benchmarks", script) |
| 3 | + # make revision && Rscript inst/benchmarks/boot.R ## install to various libs with various compilation flags |
| 4 | + # R -q -e 'data.table:::benchmark.data.table(libs=list.dirs("library/gcc"))' |
| 5 | + fn = setNames(file.path("inst","benchmarks", script), script) ## this path only for development, ultimately use system.file(package="data.table", "benchmarks", script) |
5 | 6 | desc = if (length(desc)) paste0(" ", desc) else "" |
| 7 | + if (is.null(libs)) libs = .libPaths()[1L] |
6 | 8 | mth = max.th() |
7 | 9 | ths = unique(c(1L, as.integer(mth * c(0.1,0.25,0.5,0.75,1)))) |
8 | 10 | ths = ths[ths>0L] |
9 | 11 | cat("benchmark.data.table() running: ", names(fn), "\n", sep="") |
10 | 12 | init = proc.time()[[3L]] |
11 | | - for (th in ths) { |
12 | | - cmd = sprintf("R_DATATABLE_NUM_THREADS=%s R_DATATABLE_NUM_PROCS_PERCENT=100 %s %s%s", th, rbin, fn, desc) |
13 | | - cat(cmd,"\n",sep="") |
14 | | - system(cmd) |
| 13 | + for (lib in libs) { |
| 14 | + for (th in ths) { |
| 15 | + cmd = sprintf("R_LIBS_USER=%s R_DATATABLE_NUM_THREADS=%s R_DATATABLE_NUM_PROCS_PERCENT=100 %s %s%s", lib, th, rbin, fn, desc) |
| 16 | + cat(cmd,"\n",sep="") |
| 17 | + system(cmd) |
| 18 | + } |
15 | 19 | } |
16 | 20 | t = proc.time()[[3L]] |
17 | 21 | cat("Benchmarks in ", names(fn), " completed in ", trunc(t-init), "s\n", sep="") |
18 | 22 | invisible(TRUE) |
19 | 23 | } |
20 | | - |
21 | 24 | max.th = function() { |
22 | 25 | old = setDTthreads(0L) |
23 | 26 | th = getDTthreads() |
24 | 27 | setDTthreads(old) |
25 | 28 | th |
26 | 29 | } |
27 | | - |
28 | 30 | omp = function() { |
29 | 31 | omp = capture.output(th<-getDTthreads(verbose=TRUE)) |
30 | 32 | val = function(x) tail(strsplit(x, " ", fixed=TRUE)[[1L]], 1L) |
@@ -93,3 +95,8 @@ benchmark = function(num, expr, desc=NA_character_) { |
93 | 95 | if (num>0) fwrite(l, "benchmarks.csv", append=TRUE, row.names=FALSE) |
94 | 96 | invisible(TRUE) |
95 | 97 | } |
| 98 | +summary.benchmark = function() { |
| 99 | + d = fread("benchmarks.csv") |
| 100 | + d[,.(cflags, num, fun, args, desc, th, user_self, sys_self, elapsed)] |
| 101 | +} |
| 102 | + |
0 commit comments