Skip to content

Instantly share code, notes, and snippets.

@justinas
Created November 21, 2019 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinas/31c7aa1265098a3fcdfee7def69bc4ee to your computer and use it in GitHub Desktop.
Save justinas/31c7aa1265098a3fcdfee7def69bc4ee to your computer and use it in GitHub Desktop.
Conditionally apply funtime::timed
[package]
name = "sandbox"
version = "0.1.0"
authors = ["User Name <foo@bar>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
profiling = ["funtime"]
[dependencies]
funtime = { version = "0.3", optional = true }
#[cfg_attr(feature = "profiling", funtime::timed)]
fn foo() {
std::thread::sleep(std::time::Duration::new(1, 0));
}
fn main() {
foo();
}
@justinas
Copy link
Author

$ cargo run
$ cargo run --features profiling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment