Skip to content

Commit b7d1dab

Browse files
author
luke
committed
Add replications in timing test to reduce variability.
git-svn-id: https://svn.r-project.org/R/trunk@86204 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent fbd0159 commit b7d1dab

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tests/reg-tests-1c.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ stopifnot(!is.unsorted(NA))
5454
## str(.) for large factors should be fast:
5555
u <- as.character(runif(1e5))
5656
dummy <- str(u); dummy <- str(u); # force compilation of str
57-
t1 <- max(0.001, system.time(str(u))[[1]]) # get a baseline > 0
57+
R <- 50
58+
t1 <- max(0.001, system.time(replicate(R, str(u))[[1]])) # get a baseline > 0
5859
uf <- factor(u)
59-
(t2 <- system.time(str(uf))[[1]]) / t1 # typically around 1--2
60+
(t2 <- system.time(replicate(R, str(uf)))[[1]]) / t1 # typically around 5--10
6061
stopifnot(t2 / t1 < 30)
6162
## was around 600--850 for R <= 3.0.1
6263

0 commit comments

Comments
 (0)