Skip to content

Commit 256a6e4

Browse files
committed
Include additional data in the json output
1 parent 579faca commit 256a6e4

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/librustc/session/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ impl Session {
841841

842842
pub fn save_json_results(&self) {
843843
let profiler = self.self_profiling.borrow();
844-
profiler.save_results();
844+
profiler.save_results(&self.opts);
845845
}
846846

847847
pub fn print_perf_stats(&self) {

src/librustc/util/profiling.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,17 @@ impl SelfProfiler {
269269
writeln!(lock, "Incremental: {}", incremental).unwrap();
270270
}
271271

272-
pub fn save_results(&self) {
273-
fs::write("self_profiler_results.json", self.data.json()).unwrap();
272+
pub fn save_results(&self, opts: &Options) {
273+
let category_data = self.data.json();
274+
let compilation_options = format!("{{ \"optimization_level\": \"{:?}\", \"incremental\": {} }}",
275+
opts.optimize,
276+
if opts.incremental.is_some() { "true" } else { "false" });
277+
278+
let json = format!("{{ \"category_data\": {}, \"compilation_options\": {} }}",
279+
category_data,
280+
compilation_options);
281+
282+
fs::write("self_profiler_results.json", json).unwrap();
274283
}
275284

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

0 commit comments

Comments
 (0)