This works around some performance problems running Android under QEMU. Calling pfm_initialize was very slow, and was called during dynamic initialization (before main or when loaded as a shared library). This happened whenever benchmark was linked, even if no benchmarks were run.
Instead, call pfm_initialize at most once, and only when one of:
PerfCounters::Initialize is called
PerfCounters::Create is called with a non-empty counter list
PerfCounters::IsCounterSupported is called
The return value of the first pfm_initialize() is saved and returned from all subsequent PerfCounters::Initialize calls.
This works around some performance problems running Android under QEMU. Calling
pfm_initialize
was very slow, and was called during dynamic initialization (beforemain
or when loaded as a shared library). This happened whenever benchmark was linked, even if no benchmarks were run.Instead, call
pfm_initialize
at most once, and only when one of:PerfCounters::Initialize
is calledPerfCounters::Create
is called with a non-empty counter listPerfCounters::IsCounterSupported
is calledThe return value of the first
pfm_initialize()
is saved and returned from all subsequentPerfCounters::Initialize
calls.