[Smtk-developers] Attribute callback benchmarks

David Thompson david.thompson at kitware.com
Tue Aug 11 11:38:33 EDT 2015


Hi all,

I am working on adding callbacks to notify applications when attributes are changed. One of the concerns has been the overhead of callbacks on value change events, since these could conceivably happen frequently. I've done some preliminary benchmarking to quantify the cost of calling C++ lambdas each time an attribute value changes. The results are below.

To benchmark the timing, I create an attribute with a single DoubleItem and repeatedly change the value of the DoubleItem to a random number. The timings were done on my MacBookPro running Mac OS X 10.9.

Without any changes to SMTK:
1. Baseline:                   0.355 +/- 0.01 usec per setValue() call.
With callback code added:
2. No callbacks registered:    1.238 +/- 0.01 usec per setValue() call.
3. With 1000 empty callbacks: 21.32  +/- 0.20 usec per setValue() call.
4. With 1 trivial callback:    1.281 +/- 0.02 usec per setValue() call.

These times were averaged over 5-6 runs, with each run consisting of 1-million setValue calls (except for the version with 1000 callbacks registered, which used 100,000 setValue calls per run).

I have not evaluated signal/slot libraries; the callback code uses smtk::function<void(const EventType&)> to hold references to callbacks.

	David


More information about the Smtk-developers mailing list