Open timelyportfolio opened 9 years ago
Actually, just tested these with about the same results as the env_method
.
benches = lapply(
n,
function(ntest){
microbenchmark(
rlist_method3 = {
Result <<- List()
for(i in seq_len(ntest)) {
Result <<- Result$append(i)
}
},
rlist_method4 = {
Result <<- List()
for(i in seq_len(ntest)) {
.GlobalEnv$Result[[as.character(i)]] <- i
}
}
, times = 1L
)
}
)
These results don't match up with my experience. Might need to use line profiler.
[[1]]
Unit: milliseconds
expr min lq mean median uq max neval
rlist_method3 8.592473 8.592473 8.592473 8.592473 8.592473 8.592473 1
rlist_method4 9.610418 9.610418 9.610418 9.610418 9.610418 9.610418 1
[[2]]
Unit: milliseconds
expr min lq mean median uq max neval
rlist_method3 90.75483 90.75483 90.75483 90.75483 90.75483 90.75483 1
rlist_method4 127.60269 127.60269 127.60269 127.60269 127.60269 127.60269 1
[[3]]
Unit: seconds
expr min lq mean median uq max neval
rlist_method3 1.569715 1.569715 1.569715 1.569715 1.569715 1.569715 1
rlist_method4 4.020317 4.020317 4.020317 4.020317 4.020317 4.020317 1
[[4]]
Unit: seconds
expr min lq mean median uq max neval
rlist_method3 202.8104 202.8104 202.8104 202.8104 202.8104 202.8104 1
rlist_method4 858.1140 858.1140 858.1140 858.1140 858.1140 858.1140 1
Thanks for reporting this! I'll take a look and see if I can improve the existing code.
I'm sure my ignorance will show here, but I thought this was a useful reference benchmark for
list.append
based on this StackOverflow discussion. Feel free to disregard.with result on my machine