Skip to content

Commit 4c8cc14

Browse files
committed
Replace TimeLine with SelfProfiler
1 parent 913ad6d commit 4c8cc14

File tree

12 files changed

+155
-435
lines changed

12 files changed

+155
-435
lines changed

src/librustc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ pub mod util {
136136
pub mod common;
137137
pub mod ppaux;
138138
pub mod nodemap;
139-
pub mod time_graph;
140139
pub mod profiling;
141140
pub mod bug;
142141
}

src/librustc/util/profiling.rs

+23-8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::borrow::Cow;
12
use std::fs;
23
use std::io::{BufWriter, Write};
34
use std::mem;
@@ -20,12 +21,12 @@ pub enum ProfileCategory {
2021
Other,
2122
}
2223

23-
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
24+
#[derive(Clone, Debug, Eq, PartialEq)]
2425
pub enum ProfilerEvent {
2526
QueryStart { query_name: &'static str, category: ProfileCategory, time: u64 },
2627
QueryEnd { query_name: &'static str, category: ProfileCategory, time: u64 },
27-
GenericActivityStart { category: ProfileCategory, time: u64 },
28-
GenericActivityEnd { category: ProfileCategory, time: u64 },
28+
GenericActivityStart { category: ProfileCategory, label: Cow<'static, str>, time: u64 },
29+
GenericActivityEnd { category: ProfileCategory, label: Cow<'static, str>, time: u64 },
2930
IncrementalLoadResultStart { query_name: &'static str, time: u64 },
3031
IncrementalLoadResultEnd { query_name: &'static str, time: u64 },
3132
QueryCacheHit { query_name: &'static str, category: ProfileCategory, time: u64 },
@@ -75,17 +76,27 @@ impl SelfProfiler {
7576
}
7677

7778
#[inline]
78-
pub fn start_activity(&mut self, category: ProfileCategory) {
79+
pub fn start_activity(
80+
&mut self,
81+
category: ProfileCategory,
82+
label: impl Into<Cow<'static, str>>,
83+
) {
7984
self.record(ProfilerEvent::GenericActivityStart {
8085
category,
86+
label: label.into(),
8187
time: self.get_time_from_start(),
8288
})
8389
}
8490

8591
#[inline]
86-
pub fn end_activity(&mut self, category: ProfileCategory) {
92+
pub fn end_activity(
93+
&mut self,
94+
category: ProfileCategory,
95+
label: impl Into<Cow<'static, str>>,
96+
) {
8797
self.record(ProfilerEvent::GenericActivityEnd {
8898
category,
99+
label: label.into(),
89100
time: self.get_time_from_start(),
90101
})
91102
}
@@ -273,11 +284,12 @@ impl SelfProfiler {
273284
nanos,
274285
thread_id,
275286
).unwrap(),
276-
GenericActivityStart { category, time: _ } =>
287+
GenericActivityStart { category, label, time: _ } =>
277288
write!(file,
278289
"{{
279290
\"GenericActivityStart\": {{\
280291
\"category\": \"{:?}\",\
292+
\"label\": \"{}\",\
281293
\"time\": {{\
282294
\"secs\": {},\
283295
\"nanos\": {}\
@@ -286,15 +298,17 @@ impl SelfProfiler {
286298
}}\
287299
}}",
288300
category,
301+
label,
289302
secs,
290303
nanos,
291304
thread_id,
292305
).unwrap(),
293-
GenericActivityEnd { category, time: _ } =>
306+
GenericActivityEnd { category, label, time: _ } =>
294307
write!(file,
295308
"{{\
296309
\"GenericActivityEnd\": {{\
297310
\"category\": \"{:?}\",\
311+
\"label\": \"{}\",\
298312
\"time\": {{\
299313
\"secs\": {},\
300314
\"nanos\": {}\
@@ -303,6 +317,7 @@ impl SelfProfiler {
303317
}}\
304318
}}",
305319
category,
320+
label,
306321
secs,
307322
nanos,
308323
thread_id,
@@ -418,7 +433,7 @@ impl SelfProfiler {
418433
secs,
419434
nanos,
420435
thread_id,
421-
).unwrap()
436+
).unwrap(),
422437
}
423438
}
424439
}

src/librustc/util/time_graph.rs

-268
This file was deleted.

0 commit comments

Comments
 (0)