|
1 | | -benchmark.data.table = function(script="benchmarks.Rraw", pct=100, th=2, rbin="Rscript", desc=character()) { |
| 1 | +benchmark.data.table = function(script="benchmarks.Rraw", rbin="Rscript", desc=character()) { |
2 | 2 | stopifnot(length(script)==1L) |
3 | 3 | # make revision && make build && make install && R -q -e 'data.table:::benchmark.data.table()' |
4 | 4 | fn = setNames(file.path("inst","benchmarks", script), script) ## this path only for development, finally use system.file(package="data.table", "benchmarks", script) |
5 | 5 | desc = if (length(desc)) paste0(" ", desc) else "" |
| 6 | + mth = max.th() |
| 7 | + ths = unique(c(1L, as.integer(mth * c(0.1,0.25,0.5,0.75,1)))) |
| 8 | + ths = ths[ths>0L] |
6 | 9 | cat("benchmark.data.table() running: ", names(fn), "\n", sep="") |
7 | 10 | init = proc.time()[[3L]] |
8 | | - for (p in pct) { |
9 | | - cmd = sprintf("R_DATATABLE_NUM_PROCS_PERCENT=%s R_DATATABLE_NUM_THREADS=%s %s %s%s", p, th, rbin, fn, desc) |
| 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="") |
10 | 14 | system(cmd) |
11 | 15 | } |
12 | 16 | t = proc.time()[[3L]] |
13 | 17 | cat("Benchmarks in ", names(fn), " completed in ", trunc(t-init), "s\n", sep="") |
14 | 18 | invisible(TRUE) |
15 | 19 | } |
16 | 20 |
|
| 21 | +max.th = function() { |
| 22 | + old = setDTthreads(0L) |
| 23 | + th = getDTthreads() |
| 24 | + setDTthreads(old) |
| 25 | + th |
| 26 | +} |
| 27 | + |
17 | 28 | omp = function() { |
18 | 29 | omp = capture.output(th<-getDTthreads(verbose=TRUE)) |
19 | 30 | val = function(x) tail(strsplit(x, " ", fixed=TRUE)[[1L]], 1L) |
|
0 commit comments