# Kaleidoscope IIIb (useR! 2011)

August 18, 2011
By

(This article was first published on Why? » R, and kindly contributed to R-bloggers)

## O. Mersmann - The microbenchmark package

SURGEON GENERAL’s WARNING: Microbenchmarks can lead to a distorted view of reality and massive loss of productivity

For a higher-order benchmarking package check out the rbenchmark package on R (suggestion from the speaker).

Why do we need micro-benchmarking? A simple example showed that it is currently very difficult to benchmark 1+1 and f= function() NULL  using system.time. Microbenchmark has a very simple interface. Unlike system.time, MB measures the times of each individual function call. Produces summary statistics and plots.

### How does microbenchmark() work?

• Linux: clock_getttime(), gethrtime();
• MAC: mach_timebase_info();
• Windows: QueryPerformanceCounter(), QueryPerformanceFrequency()

### Challenges:

1. Precision of clock is unknown: clock could drift, timing might be zero, might observe discrete values;
2. Clock only measures elapsed time. Some of this time may not actually be the R process.
Countermeasures to these problems include configurable CPU warm-up phase, configurable order of execution, warning if timings underflow. There are problems with MacOS X and Windows XP.

### Planned features:

• More plotting functions;
• Possibly use OS API;
• Better diagnostic messages;
• Estimate clock granularity.

## Paul Murrell – Vector image processing

Problem: convert a pretty pdf map into an interactive SVG document.
PDF -> R -> SVG
Discussion of recent improvements to the core R graphics engine and grImport. Using the svg would produce a static svg. However, the gridSVG produces an interactive SVG. Use grid.animate, .garnish, .hyperlink, .script to make the picture interactive.
Looks like a very nice package.