Crate flame [] [src]

Here's an example of how to use some of FLAMEs APIs:

extern crate flame;

use std::fs::File;

pub fn main() {
    // Manual `start` and `end`
    flame::start("read file");
    let x = read_a_file();
    flame::end("read file");

    // Time the execution of a closure.  (the result of the closure is returned)
    let y = flame::span_of("database query", || query_database());

    // Time the execution of a block by creating a guard.
    let z = {
        let _guard = flame::start_guard("cpu-heavy calculation");
        cpu_heavy_operations_1();
        // Notes can be used to annotate a particular instant in time.
        flame::note("something interesting happened", None);
        cpu_heavy_operations_2()
    };

    // Dump the report to disk
    flame::dump_html(&mut File::create("flame-graph.html").unwrap()).unwrap();

    // Or read and process the data yourself!
    let spans = flame::spans();

    println!("{} {} {}", x, y, z);
}

Structs

Note

A note for use in debugging.

Span

A named timespan.

SpanGuard
Thread

A collection of events that happened on a single thread.

Functions

clear

Clears all of the recorded info that Flame has tracked.

commit_thread
debug

Prints all of the frames to stdout.

dump_html
dump_json
dump_stdout
dump_text_to_writer
end

Ends the current Span and returns the number of nanoseconds that passed.

end_collapse

Ends the current Span and returns the number of nanoseconds that passed.

end_with

Ends the current Span and returns a given result.

note

Records a note on the current Span.

span_of

Starts and ends a Span that lasts for the duration of the function f.

spans

Returns a list of spans from the current thread

start

Starts a new Span

start_guard

Starts a Span and also returns a SpanGuard.

threads

Type Definitions

StrCow