Persil

Docs.rs Crates.io

Table of Contents

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

Installing

Add this to your Cargo.toml [dependencies] persil = "0.1.0"

If you have cargo-edit installed cargo add persil

Usage

``rust // You have to callinitat 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::initwithpath("my_application", "./");

// 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 = parseexpression().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); ```

Enable the profiler in your binary.

To enable profiling, you have to enable the profiler feature in this crate. Otherwise the trace function will do nothing.

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: ```sh

if you changed the path to the results, use the new path

summarize trace/my_application ```

For more information checkout the measureme repository.