A proc macro to insert appropriate flame::start_guard(_)
calls (for use with
flame)
This proc macro requires Rust 1.30. Because flamer is a proc macro attribute, it uses APIs stabilized in Rust 1.30.
Usage:
In your Cargo.toml add flame
and flamer
to your dependencies:
[]
= "0.2.2"
= "0.5"
Then in your crate root, add the following:
extern crate flame;
extern crate flamer;
// The item to apply `flame` to goes here.
Unfortunately, currently stable Rust doesn't allow custom attributes on modules.
To use #[flame]
on modules you need a nightly Rust with
#![feature(proc_macro_hygiene)]
in the crate root
(related issue):
extern crate flame;
extern crate flamer;
You may also opt for an optional dependency. In that case your Cargo.toml should have:
[]
= { = "0.2.2", = true }
= { = "0.3", = true }
[]
= []
= ["flame", "flamer"]
And your crate root should contain:
extern crate flame;
extern crate flamer;
// as well as the following instead of `#[flame]`
// The item to apply `flame` to goes here.
For nightly module support, also add
#![cfg_attr(feature = "flame_it", feature(proc_macro_hygiene))]
in the crate
root:
extern crate flame;
extern crate flamer;
// as well as the following instead of `#[flame]`
You should then be able to annotate every item (alas, currently not the whole
crate; see the
custom inner attribute issue
for more details) 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.
Full Example
use File;
use flame as f;
use flame;
Refer to flame's documentation to see how output works.
License: Apache 2.0