How do one use the list-argument in the microbenchmark
function.
I want to microbenchmark the same function with different inputs as in
microbenchmark(j1 = {sample(1e5)},
j2 = {sample(2e5)},
j3 = {sample(3e5)})
The following is not going to fly, as the list will just contain vectors and not unevaluated expressions.
microbenchmark(list = list(j1 = {sample(1e5)},
j2 = {sample(2e5)},
j3 = {sample(3e5)))
I would also want to generate the list using e.g. lapply
.
new.env()
, you can just put the statement inside alocal
:local({s = s; bquote(sample(.(s)))})
(bquote
andsubstitute
both work but I generally preferbquote
for readability). In fact, this simple case even works without local environment (but that doesn’t generalise):jobs = lapply(1000 * 1 : 3, function (s) bquote(sample(.(s))))
. – Absentminded