Skip to content

Commit ea15862

Browse files
committed
always run many threads
1 parent 3a55ef0 commit ea15862

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

R/benchmark.data.table.R

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,30 @@
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()) {
22
stopifnot(length(script)==1L)
33
# make revision && make build && make install && R -q -e 'data.table:::benchmark.data.table()'
44
fn = setNames(file.path("inst","benchmarks", script), script) ## this path only for development, finally use system.file(package="data.table", "benchmarks", script)
55
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]
69
cat("benchmark.data.table() running: ", names(fn), "\n", sep="")
710
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="")
1014
system(cmd)
1115
}
1216
t = proc.time()[[3L]]
1317
cat("Benchmarks in ", names(fn), " completed in ", trunc(t-init), "s\n", sep="")
1418
invisible(TRUE)
1519
}
1620

21+
max.th = function() {
22+
old = setDTthreads(0L)
23+
th = getDTthreads()
24+
setDTthreads(old)
25+
th
26+
}
27+
1728
omp = function() {
1829
omp = capture.output(th<-getDTthreads(verbose=TRUE))
1930
val = function(x) tail(strsplit(x, " ", fixed=TRUE)[[1L]], 1L)

0 commit comments

Comments
 (0)