[Rd] Benchmark code, but avoid printing

Gábor Csárdi csardi.gabor at gmail.com
Fri Jan 2 18:02:57 CET 2015


Dear all,

I am trying to benchmark code that occasionally prints on the screen
and I want to
suppress the printing. Is there an idiom for this?

If I do

sink(tempfile)
microbenchmark(...)
sink()

then I'll be also measuring the costs of writing to tempfile. I could
also sink to /dev/null, which is probably fast, but that is not
portable.

Is there a better solution? Is writing to a textConnection() better?

Thanks, Best,
Gabor



More information about the R-devel mailing list