facebook/rocksdb — pull request #242 by tdfischer (2014-08-22 22:36:41+00:00)
Title: Refactor PerfStepTimer to automatically stop on destruct

This eliminates the need to remember to call PERF_TIMER_STOP when a section has
been timed. This allows more useful design with the perf timers and enables
possible return value optimizations. Simplistic example:

```c++
class Foo {
public:
Foo(int v) : m_v(v);
private:
int m_v;
}

Foo makeFrobbedFoo(int *errno)
{
*errno = 0;
return Foo(1);
}

Foo bar(int *errno)
{
PERF_TIMER_INIT(some_timer);

return makeFrobbedFoo(errno);
}

int main(int argc, char[] argv)
{
Foo f;
int errno;

f = bar(&errno);

if (errno)
return -1;
return 0;
}
```

After bar() is called, perf_context.some_timer would be incremented as if
Stop(&perf_context.some_timer) was called at the end, and the compiler is still
able to produce optimizations on the return value from makeFrobbedFoo() through
to main().