1068: profiling crate first draft r=matklad a=pasa

I've made this first draft for #961 
Could you look at it? Is this something what you are looking for?
It has lack of tests. I can't figure out how to test stderr output in rust right now. Do you have some clues?
Additionally I'm thinking about to implement procedural  macros to annotate methods with this profiler. Will it be helpful?



Co-authored-by: Sergey Parilin <sergey.parilin@fxdd.com>
This commit is contained in:
bors[bot] 2019-04-03 09:09:11 +00:00
commit c6c88070c4
10 changed files with 193 additions and 10 deletions

View file

@ -1,12 +1,13 @@
mod analysis_stats;
use std::{fs, io::Read, path::Path, time::Instant};
use std::{fs, io::Read, path::Path};
use clap::{App, Arg, SubCommand};
use ra_ide_api::file_structure;
use ra_syntax::{SourceFile, TreeArc, AstNode};
use tools::collect_tests;
use flexi_logger::Logger;
use ra_prof::profile;
type Result<T> = ::std::result::Result<T, failure::Error>;
@ -27,13 +28,11 @@ fn main() -> Result<()> {
.get_matches();
match matches.subcommand() {
("parse", Some(matches)) => {
let start = Instant::now();
let _p = profile("parsing");
let file = file()?;
let elapsed = start.elapsed();
if !matches.is_present("no-dump") {
println!("{}", file.syntax().debug_dump());
}
eprintln!("parsing: {:?}", elapsed);
::std::mem::forget(file);
}
("symbols", _) => {