Struct cpuprofiler::Profiler
[−]
[src]
pub struct Profiler { /* fields omitted */ }
The Profiler
The Profiler
gives access to the cpuprofiler library.
By storing the state of the profiler and limiting access
we make the FFI safer.
Methods
impl Profiler
[src]
fn state(&self) -> ProfilerState
Returns the profiler state
Examples
use cpuprofiler::PROFILER; println!("{}", PROFILER.lock().unwrap().state());
fn start<T: Into<Vec<u8>>>(&mut self, fname: T) -> Result<(), Error>
Start the profiler
Will begin sampling once this function has been called
and will not stop until the stop
function has been called.
This function takes as an argument a filename. The filename must be
both valid Utf8 and a valid CString
.
Failures
- The profiler is currently
Active
. fname
is not a validCString
.fname
is not valid Utf8.fname
is not a file.- The user does not have write access to the file.
- An internal failure from the cpuprofiler library.
fn stop(&mut self) -> Result<(), Error>
Stop the profiler.
This will stop the profiler if it Active
and return
an error otherwise.
Failures
- The profiler is
NotActive
.