Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ name = "inferno-collapse-vtune"
path = "src/bin/collapse-vtune.rs"
required-features = ["cli"]

[[bin]]
name = "inferno-collapse-vsprof"
path = "src/bin/collapse-vsprof.rs"
required-features = ["cli"]

[[bin]]
name = "inferno-collapse-guess"
path = "src/bin/collapse-guess.rs"
Expand Down
52 changes: 52 additions & 0 deletions src/bin/collapse-vsprof.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
use std::io;
use std::path::PathBuf;

use clap::Parser;
use env_logger::Env;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: we should really move over to tracing.

use inferno::collapse::vsprof::Folder;
use inferno::collapse::Collapse;

#[derive(Debug, Parser)]
#[clap(
name = "inferno-collapse-vsprof",
about,
after_help = "\
[1] This processes the call tree summary of the built in Visual Studio profiler"
)]
struct Opt {
// ************* //
// *** FLAGS *** //
// ************* //
/// Silence all log output
#[clap(short = 'q', long = "quiet")]
quiet: bool,

/// Verbose logging mode (-v, -vv, -vvv)
#[clap(short = 'v', long = "verbose", parse(from_occurrences))]
verbose: usize,

// ************ //
// *** ARGS *** //
// ************ //
#[clap(value_name = "PATH")]
/// Call tree summary file from the built in Visual Studio profiler, or STDIN if not specified
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::default().collapse_file_to_stdout(opt.infile)
}
6 changes: 4 additions & 2 deletions src/collapse/guess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::io::{self, Cursor};

use log::{error, info};

use crate::collapse::{self, dtrace, perf, sample, vtune, Collapse};
use crate::collapse::{self, dtrace, perf, sample, vsprof, vtune, Collapse};

const LINES_PER_ITERATION: usize = 10;

Expand Down Expand Up @@ -69,10 +69,11 @@ impl Collapse for Folder {
};
let mut sample = sample::Folder::default();
let mut vtune = vtune::Folder::default();
let mut vsprof = vsprof::Folder::default();

// Each Collapse impl gets its own flag in this array.
// It gets set to true when the impl has been ruled out.
let mut not_applicable = [false; 4];
let mut not_applicable = [false; 5];

let mut buffer = String::new();
loop {
Expand Down Expand Up @@ -106,6 +107,7 @@ impl Collapse for Folder {
try_collapse_impl!(dtrace, 1);
try_collapse_impl!(sample, 2);
try_collapse_impl!(vtune, 3);
try_collapse_impl!(vsprof, 4);

if eof {
break;
Expand Down
7 changes: 7 additions & 0 deletions src/collapse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ pub mod sample;
/// [crate-level documentation]: ../../index.html
pub mod vtune;

/// Stack collapsing for the output of the [Visual Studio built-in profiler](https://docs.microsoft.com/en-us/visualstudio/profiling/profiling-feature-tour?view=vs-2019).
///
/// See the [crate-level documentation] for details.
///
/// [crate-level documentation]: ../../index.html
pub mod vsprof;

// DEFAULT_NTHREADS is public because we use it in the help text of the binaries,
// but it doesn't need to be exposed to library users, hence #[doc(hidden)].
#[doc(hidden)]
Expand Down
Loading