Skip to content

Commit

Permalink
Include additional data in the json output
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleywiser committed Aug 2, 2018
1 parent 579faca commit 256a6e4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/librustc/session/mod.rs
Expand Up @@ -841,7 +841,7 @@ impl Session {

pub fn save_json_results(&self) {
let profiler = self.self_profiling.borrow();
profiler.save_results();
profiler.save_results(&self.opts);
}

pub fn print_perf_stats(&self) {
Expand Down
13 changes: 11 additions & 2 deletions src/librustc/util/profiling.rs
Expand Up @@ -269,8 +269,17 @@ impl SelfProfiler {
writeln!(lock, "Incremental: {}", incremental).unwrap();
}

pub fn save_results(&self) {
fs::write("self_profiler_results.json", self.data.json()).unwrap();
pub fn save_results(&self, opts: &Options) {
let category_data = self.data.json();
let compilation_options = format!("{{ \"optimization_level\": \"{:?}\", \"incremental\": {} }}",
opts.optimize,
if opts.incremental.is_some() { "true" } else { "false" });

let json = format!("{{ \"category_data\": {}, \"compilation_options\": {} }}",
category_data,
compilation_options);

fs::write("self_profiler_results.json", json).unwrap();
}

pub fn record_activity<'a>(&'a mut self, category: ProfileCategory) -> ProfilerActivity<'a> {
Expand Down

0 comments on commit 256a6e4

Please sign in to comment.