extern crate thread_profiler;
use thread_profiler::ProfileScope;
use std::vec::Vec;
fn main() {
println!(
"Running with thread_profler. Names prepended by '{}'",
module_path!()
);
thread_profiler::register_thread_with_profiler();
long_complex_function();
let output = "./profile.json";
println!("Writing output to {}", output);
thread_profiler::write_profile(output);
}
fn long_complex_function() {
ProfileScope::new(format!("{}: {}", module_path!(), "covering function"));
let mut v = Vec::new();
{
ProfileScope::new(format!("{}: {}", module_path!(), "section 1"));
v.push(1);
}
{
ProfileScope::new(format!("{}: {}", module_path!(), "section 2"));
v.push(2);
}
v.push(3)
}