smarr / ReBenchDB

ReBenchDB records benchmark results and provides customizable reporting to track and analyze run-time performance of software programs.
MIT License
13 stars 6 forks source link

Prefer R's bultin pipe and use droplevels() more strategically to improve performance #94

Closed smarr closed 2 years ago

smarr commented 2 years ago

After looking at the execution in a profiler, there were a few things that stuck out as unusual/undesirable.

The magrittr pipe is a little slower than R's builtin pipe operator, which is now available (wasn't we this project started).

droplevels() also seems to take enough time to warrant more careful use. Instead of using it everywhere, I am now using it only when I want to look at the levels, for instance to iterate over them.

The investigation also revealed that up to 20% of run-time is spent on checking whether the terminal can represent colors, which seems a lot of redundant work, but that's an issue in the rlang package: https://github.com/r-lib/rlang/issues/1444

As a minor change, this fixes the script for running from the command-line, which was broken after introducing displaying the environment.

@HumphreyHCB please check (to avoid unexpected clashes) @sophie-kaleba might be interesting for your R scripts.

smarr commented 2 years ago

The last change I added before merging also disables the rendering of warmup plots in the executor comparison. This isn't something I usually look at.