#profiling #compiler-plugin #flame-graph

flamer

a procedural macro to insert flame::start_guard(_) calls

11 releases

0.3.0 Nov 6, 2018
0.2.5 Jul 13, 2018
0.2.3 Jun 24, 2018
0.2.0 Jan 8, 2018
0.1.2 Jul 8, 2016

#7 in Profiling

Download history 23/week @ 2018-10-11 46/week @ 2018-10-18 32/week @ 2018-10-25 32/week @ 2018-11-01 107/week @ 2018-11-08 149/week @ 2018-11-15 45/week @ 2018-11-22 114/week @ 2018-11-29 77/week @ 2018-12-06 50/week @ 2018-12-13 129/week @ 2018-12-20 122/week @ 2018-12-27 85/week @ 2019-01-03

342 downloads per month
Used in 2 crates

Apache-2.0

8KB
123 lines

A plugin to insert appropriate flame::start_guard(_) calls (for use with flame)

Build Status Current Version Docs

This needs a nightly rustc! Because flamer is a compiler plugin, it uses unstable APIs, which are not available on stable or beta. It may be possible to extend flamer to allow use with syntex, but this hasn't been tried yet.

Usage:

In your Cargo.toml add flame and flamer to your dependencies:

[dependencies]
flame = "0.2.2"
flamer = "0.3"

Then in your crate root, add the following:

#![feature(proc_macro_hygiene)]
#[macro_use] extern crate flamer;

extern crate flame;

#[flame]
// The item to apply `flame` to goes here.

You may also opt for an optional dependency. In that case your Cargo.toml should have:

[dependencies]
flame = { version = "0.2.2", optional = true }
flamer = { version = "0.3", optional = true }

[features]
default = []
flame_it = ["flame", "flamer"]

And your crate root should contain:

#![cfg_attr(feature="flame_it", feature(proc_macro_hygiene))]

#[cfg(feature="flame_it")]
#[macro_use] extern crate flamer;

#[cfg(feature="flame_it")]
extern crate flame;

// as well as the following instead of `#[flame]`
#[cfg_attr(feature="flame_it", flame)]
// The item to apply `flame` to goes here.
mod flamed_module { .. }

You should then be able to annotate every item (alas, currently not the whole crate) with #[flame] annotations. You can also use #[noflame] annotations to disable instrumentations for subitems of #[flame]d items. Note that this only instruments the annotated methods, it does not print out the results.

The flame annotation can also take an optional parameter specifying a string to prefix to enclosed method names. This is especially useful when annotating multiple methods with the same name, but in different modules.

#[flame("prefix")]
fn method_name() {
    //The corresponding block on the flamegraph will be named "prefix::method_name"
}

Refer to flame's documentation to see how output works.

License: Apache 2.0

Dependencies

~2MB
~35K SLoC

  • flame 0.2.2
  • quote 0.6.9
  • syn 0.15.18+extra-traits+full+fold+parsing