library(plyr)
library(ggplot2)
t <- function(N) {
ldf <- llply(seq_len(N), function(n) data.frame(n=factor(n)))
ldfb <- rbind.fill(ldf)
NULL
}
adply(
data.frame(N=2000 * 2 ^ seq_len(4)),
1,
function(N) {
system.time(t(N[1,]))
}
) -> timing
timing
## N user.self sys.self elapsed user.child sys.child
## 1 4000 1.655 0.006 1.670 0 0
## 2 8000 4.370 0.002 4.397 0 0
## 3 16000 14.370 0.002 14.452 0 0
## 4 32000 59.716 0.023 60.168 0 0
timing$kN <- timing$N / 1000
lm(user.self~kN+I(kN^2), timing)
##
## Call:
## lm(formula = user.self ~ kN + I(kN^2), data = timing)
##
## Coefficients:
## (Intercept) kN I(kN^2)
## 1.641 -0.203 0.063
ggplot(timing) + geom_point(aes(x=kN, y=user.self))
sessionInfo()
## R version 3.0.2 (2013-09-25)
## Platform: x86_64-pc-linux-gnu (64-bit)
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
## [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] ggplot2_0.9.3.1.99 plyr_1.8.1 knitr_1.5.22
##
## loaded via a namespace (and not attached):
## [1] colorspace_1.2-4 dichromat_2.0-0 digest_0.6.4
## [4] evaluate_0.5.2 formatR_0.10.4 grid_3.0.2
## [7] gtable_0.1.2 labeling_0.2 MASS_7.3-29
## [10] munsell_0.4.2 proto_0.3-10 RColorBrewer_1.0-5
## [13] Rcpp_0.11.0 reshape2_1.2.2 scales_0.2.3.99
## [16] stringr_0.6.2 tools_3.0.2