-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
Similarly as we did for OpenMP.
Overhead for the single call may be not a problem, but when calling frollapply
in a loop, like benchmarks often do, it can get quiet severe overhead. For small input using parallel is not very useful.
Note that it is overly pessimistic case, where we call mean
on an integer of length 1.
x = sample(1e3, 2)
n = 1L
f = mean
setDTthreads(1)
system.time(frollapply(x, n, f, simplify=unlist))
# user system elapsed
# 0 0 0
setDTthreads(2) ## more than 2 would not be used anyway, because length(x)==2
system.time(frollapply(x, n, f, simplify=unlist))
# user system elapsed
# 0.002 0.007 0.006
setDTthreads(1)
system.time(for (i in 1:1e3) frollapply(x, n, f, simplify=unlist))
# user system elapsed
# 0.187 0.002 0.189
setDTthreads(2)
system.time(for (i in 1:1e3) frollapply(x, n, f, simplify=unlist))
# user system elapsed
# 1.797 8.197 5.011