[−][src]Crate persil
Persil
About
Persil is a minimal and simple library for profiling events.
It's based on rust's measureme and
is just a simple, but powerful layer ontop of measureme
.
Getting Started
Prerequisites
- Rust (I don't have any minimun required rust version, just try one of the latest)
- Tools for reading the serialized data. (See here)
- Obviously an application that you want to profile.
Installing
Add this to your Cargo.toml
[dependencies] persil = "0.1.0"
If you have cargo-edit installed
cargo add persil
Usage
// You have to call `init` at the start of the program, // with the name of your application. // // Your results will be stored in `./trace/{app-name}-{pid}` persil::init("my_application"); // To store the results in a custom path, use the `init_with_path` function. persil::init_with_path("./"); // This will enable the profiler. // // If you don't call this method, there will be results emitted. persil::enable(); // `trace` will start tracing an event. // An event is composed of a `category` and a `label`. // The `trace` function returns guard, that will stop tracing, // if it's dropped. { let _profiler = persil::trace("Parsing", "Expression"); let expr = parse_expression().unwrap(); // `_profiler` is dropped here so it will stop tracing // at the end of this scope } let profiler = persil::trace("Parsing", "Item"); parse_item().unwrap(); // You can also drop the guard manually to stop tracing. drop(profiler);
Analyze the results
To analye and display the results, you can use one of the tools in the measureme repo.
For example to use summarize
, just do:
# if you changed the path to the results, use the new path
summarize trace/my_application
For more information checkout the measureme repository.
Functions
disable | Disables the global profiler. |
enable | Enables the global profiler. |
init | Initializes the global profiler with the given application name. |
init_with_path | Initializes the global profiler and will store the results at the given path. |
trace | Starts tracing an event with the given |
try_init | Tries to initialize global profiler with the given name. |
try_init_with_path | Tries to initializethe global profiler and will store the results at the given path. |