Skip to content

Commit ee1173a

Browse files
self-profiling: Update measureme to 0.4.0 and use new RAII-based API.
1 parent f6aa64b commit ee1173a

File tree

3 files changed

+13
-33
lines changed

3 files changed

+13
-33
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -1954,9 +1954,9 @@ dependencies = [
19541954

19551955
[[package]]
19561956
name = "measureme"
1957-
version = "0.3.0"
1957+
version = "0.4.0"
19581958
source = "registry+https://github.com/rust-lang/crates.io-index"
1959-
checksum = "d09de7dafa3aa334bc806447c7e4de69419723312f4b88b80b561dea66601ce8"
1959+
checksum = "cd21b0e6e1af976b269ce062038fe5e1b9ca2f817ab7a3af09ec4210aebf0d30"
19601960
dependencies = [
19611961
"byteorder",
19621962
"memmap",

src/librustc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ byteorder = { version = "1.3" }
3737
chalk-engine = { version = "0.9.0", default-features=false }
3838
rustc_fs_util = { path = "../librustc_fs_util" }
3939
smallvec = { version = "0.6.8", features = ["union", "may_dangle"] }
40-
measureme = "0.3"
40+
measureme = "0.4"

src/librustc/util/profiling.rs

+10-30
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@ use measureme::{StringId, TimestampKind};
1414
/// MmapSerializatioSink is faster on macOS and Linux
1515
/// but FileSerializationSink is faster on Windows
1616
#[cfg(not(windows))]
17-
type Profiler = measureme::Profiler<measureme::MmapSerializationSink>;
17+
type SerializationSink = measureme::MmapSerializationSink;
1818
#[cfg(windows)]
19-
type Profiler = measureme::Profiler<measureme::FileSerializationSink>;
19+
type SerializationSink = measureme::FileSerializationSink;
20+
21+
type Profiler = measureme::Profiler<SerializationSink>;
22+
2023

2124
#[derive(Clone, Copy, Debug, PartialEq, Eq, Ord, PartialOrd)]
2225
pub enum ProfileCategory {
@@ -298,14 +301,7 @@ impl SelfProfiler {
298301
}
299302

300303
#[must_use]
301-
pub struct TimingGuard<'a>(Option<TimingGuardInternal<'a>>);
302-
303-
struct TimingGuardInternal<'a> {
304-
raw_profiler: &'a Profiler,
305-
event_id: StringId,
306-
event_kind: StringId,
307-
thread_id: u64,
308-
}
304+
pub struct TimingGuard<'a>(Option<measureme::TimingGuard<'a, SerializationSink>>);
309305

310306
impl<'a> TimingGuard<'a> {
311307
#[inline]
@@ -316,30 +312,14 @@ impl<'a> TimingGuard<'a> {
316312
) -> TimingGuard<'a> {
317313
let thread_id = thread_id_to_u64(std::thread::current().id());
318314
let raw_profiler = &profiler.profiler;
319-
raw_profiler.record_event(event_kind, event_id, thread_id, TimestampKind::Start);
320-
321-
TimingGuard(Some(TimingGuardInternal {
322-
raw_profiler,
323-
event_kind,
324-
event_id,
325-
thread_id,
326-
}))
315+
let timing_guard = raw_profiler.start_recording_interval_event(event_kind,
316+
event_id,
317+
thread_id);
318+
TimingGuard(Some(timing_guard))
327319
}
328320

329321
#[inline]
330322
pub fn none() -> TimingGuard<'a> {
331323
TimingGuard(None)
332324
}
333325
}
334-
335-
impl<'a> Drop for TimingGuardInternal<'a> {
336-
#[inline]
337-
fn drop(&mut self) {
338-
self.raw_profiler.record_event(
339-
self.event_kind,
340-
self.event_id,
341-
self.thread_id,
342-
TimestampKind::End
343-
);
344-
}
345-
}

0 commit comments

Comments
 (0)