Skip to content

Commit

Permalink
Replace TimeLine with SelfProfiler
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleywiser committed Mar 10, 2019
1 parent 913ad6d commit 4c8cc14
Show file tree
Hide file tree
Showing 12 changed files with 155 additions and 435 deletions.
1 change: 0 additions & 1 deletion src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ pub mod util {
pub mod common;
pub mod ppaux;
pub mod nodemap;
pub mod time_graph;
pub mod profiling;
pub mod bug;
}
Expand Down
31 changes: 23 additions & 8 deletions src/librustc/util/profiling.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::borrow::Cow;
use std::fs;
use std::io::{BufWriter, Write};
use std::mem;
Expand All @@ -20,12 +21,12 @@ pub enum ProfileCategory {
Other,
}

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum ProfilerEvent {
QueryStart { query_name: &'static str, category: ProfileCategory, time: u64 },
QueryEnd { query_name: &'static str, category: ProfileCategory, time: u64 },
GenericActivityStart { category: ProfileCategory, time: u64 },
GenericActivityEnd { category: ProfileCategory, time: u64 },
GenericActivityStart { category: ProfileCategory, label: Cow<'static, str>, time: u64 },
GenericActivityEnd { category: ProfileCategory, label: Cow<'static, str>, time: u64 },
IncrementalLoadResultStart { query_name: &'static str, time: u64 },
IncrementalLoadResultEnd { query_name: &'static str, time: u64 },
QueryCacheHit { query_name: &'static str, category: ProfileCategory, time: u64 },
Expand Down Expand Up @@ -75,17 +76,27 @@ impl SelfProfiler {
}

#[inline]
pub fn start_activity(&mut self, category: ProfileCategory) {
pub fn start_activity(
&mut self,
category: ProfileCategory,
label: impl Into<Cow<'static, str>>,
) {
self.record(ProfilerEvent::GenericActivityStart {
category,
label: label.into(),
time: self.get_time_from_start(),
})
}

#[inline]
pub fn end_activity(&mut self, category: ProfileCategory) {
pub fn end_activity(
&mut self,
category: ProfileCategory,
label: impl Into<Cow<'static, str>>,
) {
self.record(ProfilerEvent::GenericActivityEnd {
category,
label: label.into(),
time: self.get_time_from_start(),
})
}
Expand Down Expand Up @@ -273,11 +284,12 @@ impl SelfProfiler {
nanos,
thread_id,
).unwrap(),
GenericActivityStart { category, time: _ } =>
GenericActivityStart { category, label, time: _ } =>
write!(file,
"{{
\"GenericActivityStart\": {{\
\"category\": \"{:?}\",\
\"label\": \"{}\",\
\"time\": {{\
\"secs\": {},\
\"nanos\": {}\
Expand All @@ -286,15 +298,17 @@ impl SelfProfiler {
}}\
}}",
category,
label,
secs,
nanos,
thread_id,
).unwrap(),
GenericActivityEnd { category, time: _ } =>
GenericActivityEnd { category, label, time: _ } =>
write!(file,
"{{\
\"GenericActivityEnd\": {{\
\"category\": \"{:?}\",\
\"label\": \"{}\",\
\"time\": {{\
\"secs\": {},\
\"nanos\": {}\
Expand All @@ -303,6 +317,7 @@ impl SelfProfiler {
}}\
}}",
category,
label,
secs,
nanos,
thread_id,
Expand Down Expand Up @@ -418,7 +433,7 @@ impl SelfProfiler {
secs,
nanos,
thread_id,
).unwrap()
).unwrap(),
}
}
}
Expand Down
268 changes: 0 additions & 268 deletions src/librustc/util/time_graph.rs

This file was deleted.

Loading

0 comments on commit 4c8cc14

Please sign in to comment.