Expand description
Cpu Profiler
This crate provides safe bindings to google’s cpuprofiler library. This allows us to use statistical sampling to profile sections of code and consume the output in a number of ways using pprof.
§Installation
In order to use this library you will need to install gperftools. There are instructions in their repository but it’s roughly the following:
- Download package from releases
- Run
./configure
- Run
make install
There may be some other dependencies for your system - these are explained well in their INSTALL document. For example libunwind (> 0.99.0) is required for 64 bit systems.
§Usage
use cpuprofiler::PROFILER;
PROFILER.lock().unwrap().start("./my-prof.profile");
// Code you want to sample goes here!
PROFILER.lock().unwrap().stop();
The profiler is accessed via the static PROFILER: Mutex<Profiler>
.
We limit access this way to ensure that only one profiler is running at a time -
this is a limitation of the cpuprofiler library.
Modules§
- error
- Error handling for the cpuprofiler thanks to error_chain!
Structs§
Enums§
- Profiler
State - The state of the profiler