The source code of this class is located at Profiler.hpp.
Profiler is the entry point class coordinate collector, analyzers and interceptors,
to create a profiler instance you need to specific a model type, for example:
Profiler<CpuSampleModel> profiler;
- The profiler should have a model type
- The profiler should have exactly one collector
- The profiler may have one or more analyzers
- The profiler should not be copied, or used in multiple threads
- The collector should not know there is a class called Profiler
- The analyzers should not know there is a class called Profiler
- The interceptors should not know there is a class called Profiler
Use specified collector, replaces the old collector if this function is called twice.
Example:
Profiler<CpuSampleModel> profiler;
auto collector = profiler.useCollector<CpuSampleLinuxCollector>();
Add analyzer to analyzer list.
Example:
Profiler<CpuSampleModel> profiler;
auto analyzer = profiler.addAnalyzer<CpuSampleFrequencyAnalyzer>();
Remove analyzer from analyzer list, return whether the analyzer is in the list.
Example:
Profiler<CpuSampleModel> profiler;
auto analyzer = profiler.addAnalyzer<CpuSampleFrequencyAnalyzer>();
profiler.removeAnalyzer(analyzer);
Add interceptor to interceptor list.
Example:
Profiler<CpuSampleModel> profiler;
auto interceptor = profiler.addInterceptor<CpuSampleLinuxSymbolResolveInterceptor>();
Remove interceptor from interceptor list, return whether the interceptor is in the list.
Example:
Profiler<CpuSampleModel> profiler;
auto interceptor = profiler.addInterceptor<CpuSampleLinuxSymbolResolveInterceptor>();
profiler.removeInterceptor(interceptor);
Reset state of collectors and analyzers.
Example:
Profiler<CpuSampleModel> profiler;
// add collector, analyzer and interceptor...
while (true) {
profiler.collectFor(std::chrono::milliseconds(1000));
// output analysis results...
profiler.reset();
}
Collect and feed the data to the analyzers for the specified time.
Example:
Profiler<CpuSampleModel> profiler;
// add collector, analyzer and interceptor...
profiler.collectFor(std::chrono::milliseconds(1000));