Simple profiling utility for single-threaded applications
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Jens Pitkänen 73812ca14c Clean up formatter 2 months ago
examples Finish rest of crate? 1 year ago
src Clean up formatter 2 months ago
.gitignore Initial commit 1 year ago
.travis.yml Add to travis conf, should speed up testing 1 year ago
COPYING.md Finish rest of crate? 1 year ago
Cargo.toml Fix stperf::reset not resetting overhead 1 year ago
README.md Fix stperf::reset not resetting overhead 1 year ago

README.md

stperf

Crates.io Documentation CI

stperf (single-threaded performance profiler) is a very simple profiling utility for single-threaded applications, inspired by hprof.

Usage

Check out the docs.

#[macro_use]
extern crate stperf;

fn main() {
    use std::thread;
    use std::time::Duration;

    let process = || {
        perf_measure!("processing");
        thread::sleep(Duration::from_millis(100));
    };

    for _ in 0..2 {
        perf_measure!("main");
        for _ in 0..2 {
            perf_measure!("inner operations");
            process();
        }
        process();
    }

    stperf::print();
}

Will print out:

╶──┬╼ main                 - 100.0%, 300 ms/loop, 2 samples
   ├──┬╼ inner operations  -  66.7%, 200 ms/loop, 4 samples
   │  └───╼ processing     - 100.0%, 200 ms/loop, 4 samples
   └───╼ processing        -  33.3%, 100 ms/loop, 2 samples

License

This crate is distributed under the terms of the ISC license.