-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
19,908 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
use std::io; | ||
use std::path::PathBuf; | ||
|
||
use clap::{ArgAction, Parser}; | ||
use env_logger::Env; | ||
use inferno::collapse::xctrace::Folder; | ||
use inferno::collapse::Collapse; | ||
|
||
#[derive(Debug, Parser)] | ||
#[clap( | ||
name = "inferno-collapse-xctrace", | ||
about, | ||
after_help = r#"\ | ||
[1] This processes the result of the xctrace with `Timer Profiler` profile as run with: | ||
`xctrace record --template 'Time Profiler' --launch <executable> --output tmp.trace` | ||
or | ||
`xctrace record --template 'Time Profiler' --attach <pid|proc_name> --output tmp.trace` | ||
then | ||
xctrace export --input tmp.trace --xpath '/trace-toc/run[@number="1"]/data/table[@schema="time-profile"]' > tmp.xml | ||
"# | ||
)] | ||
struct Opt { | ||
/// Silence all log output | ||
#[clap(short = 'q', long = "quiet")] | ||
quiet: bool, | ||
|
||
/// Verbose logging mode (-v, -vv, -vvv) | ||
#[clap(short = 'v', long = "verbose", action = ArgAction::Count)] | ||
verbose: u8, | ||
|
||
// ************ // | ||
// *** ARGS *** // | ||
// ************ // | ||
/// xctrace output file, or STDIN if not specified | ||
#[clap(value_name = "PATH")] | ||
infile: Option<PathBuf>, | ||
} | ||
|
||
fn main() -> io::Result<()> { | ||
let opt = Opt::parse(); | ||
|
||
// Initialize logger | ||
if !opt.quiet { | ||
env_logger::Builder::from_env(Env::default().default_filter_or(match opt.verbose { | ||
0 => "warn", | ||
1 => "info", | ||
2 => "debug", | ||
_ => "trace", | ||
})) | ||
.format_timestamp(None) | ||
.init(); | ||
} | ||
|
||
Folder.collapse_file_to_stdout(opt.infile.as_ref()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.