Enable profiling for bench

This commit is contained in:
Aleksey Kladov 2020-02-16 18:04:08 +01:00
parent b98967d765
commit 98cc51580d
3 changed files with 10 additions and 6 deletions

View file

@ -20,6 +20,8 @@ pub(crate) enum Op {
} }
pub(crate) fn run(verbose: bool, path: &Path, op: Op) -> Result<()> { pub(crate) fn run(verbose: bool, path: &Path, op: Op) -> Result<()> {
ra_prof::init();
let start = Instant::now(); let start = Instant::now();
eprint!("loading: "); eprint!("loading: ");
let (mut host, roots) = ra_batch::load_cargo(path)?; let (mut host, roots) = ra_batch::load_cargo(path)?;

View file

@ -15,13 +15,8 @@ fn main() -> Result<()> {
fn setup_logging() -> Result<()> { fn setup_logging() -> Result<()> {
std::env::set_var("RUST_BACKTRACE", "short"); std::env::set_var("RUST_BACKTRACE", "short");
env_logger::try_init()?; env_logger::try_init()?;
ra_prof::init();
ra_prof::set_filter(match std::env::var("RA_PROFILE") {
Ok(spec) => ra_prof::Filter::from_spec(&spec),
Err(_) => ra_prof::Filter::disabled(),
});
Ok(()) Ok(())
} }

View file

@ -26,6 +26,13 @@ pub use crate::memory_usage::{Bytes, MemoryUsage};
#[global_allocator] #[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
pub fn init() {
set_filter(match std::env::var("RA_PROFILE") {
Ok(spec) => Filter::from_spec(&spec),
Err(_) => Filter::disabled(),
});
}
/// Set profiling filter. It specifies descriptions allowed to profile. /// Set profiling filter. It specifies descriptions allowed to profile.
/// This is helpful when call stack has too many nested profiling scopes. /// This is helpful when call stack has too many nested profiling scopes.
/// Additionally filter can specify maximum depth of profiling scopes nesting. /// Additionally filter can specify maximum depth of profiling scopes nesting.