Skip to content
Prev 49572 / 63421 Next

Benchmark code, but avoid printing

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