diff options
| author | Michael Woerister <michaelwoerister@posteo> | 2019-10-24 17:14:38 +0200 |
|---|---|---|
| committer | Michael Woerister <michaelwoerister@posteo> | 2019-10-24 17:14:38 +0200 |
| commit | ee1173a8ffaf51335a4eb7198cd0ce7f508abfd0 (patch) | |
| tree | d65e66347b9218a1d116d6b4da4a8792ab54642e | |
| parent | f6aa64b7b0e2a39708a1baf631f46cf02025cbe9 (diff) | |
| download | rust-ee1173a8ffaf51335a4eb7198cd0ce7f508abfd0.tar.gz rust-ee1173a8ffaf51335a4eb7198cd0ce7f508abfd0.zip | |
self-profiling: Update measureme to 0.4.0 and use new RAII-based API.
| -rw-r--r-- | Cargo.lock | 4 | ||||
| -rw-r--r-- | src/librustc/Cargo.toml | 2 | ||||
| -rw-r--r-- | src/librustc/util/profiling.rs | 40 |
3 files changed, 13 insertions, 33 deletions
diff --git a/Cargo.lock b/Cargo.lock index efcbd7b6794..8e0db18e157 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1954,9 +1954,9 @@ dependencies = [ [[package]] name = "measureme" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d09de7dafa3aa334bc806447c7e4de69419723312f4b88b80b561dea66601ce8" +checksum = "cd21b0e6e1af976b269ce062038fe5e1b9ca2f817ab7a3af09ec4210aebf0d30" dependencies = [ "byteorder", "memmap", diff --git a/src/librustc/Cargo.toml b/src/librustc/Cargo.toml index 93274ef0c92..38631224fd3 100644 --- a/src/librustc/Cargo.toml +++ b/src/librustc/Cargo.toml @@ -37,4 +37,4 @@ byteorder = { version = "1.3" } chalk-engine = { version = "0.9.0", default-features=false } rustc_fs_util = { path = "../librustc_fs_util" } smallvec = { version = "0.6.8", features = ["union", "may_dangle"] } -measureme = "0.3" +measureme = "0.4" diff --git a/src/librustc/util/profiling.rs b/src/librustc/util/profiling.rs index 0ca0ac82533..08cd68655aa 100644 --- a/src/librustc/util/profiling.rs +++ b/src/librustc/util/profiling.rs @@ -14,9 +14,12 @@ use measureme::{StringId, TimestampKind}; /// MmapSerializatioSink is faster on macOS and Linux /// but FileSerializationSink is faster on Windows #[cfg(not(windows))] -type Profiler = measureme::Profiler<measureme::MmapSerializationSink>; +type SerializationSink = measureme::MmapSerializationSink; #[cfg(windows)] -type Profiler = measureme::Profiler<measureme::FileSerializationSink>; +type SerializationSink = measureme::FileSerializationSink; + +type Profiler = measureme::Profiler<SerializationSink>; + #[derive(Clone, Copy, Debug, PartialEq, Eq, Ord, PartialOrd)] pub enum ProfileCategory { @@ -298,14 +301,7 @@ impl SelfProfiler { } #[must_use] -pub struct TimingGuard<'a>(Option<TimingGuardInternal<'a>>); - -struct TimingGuardInternal<'a> { - raw_profiler: &'a Profiler, - event_id: StringId, - event_kind: StringId, - thread_id: u64, -} +pub struct TimingGuard<'a>(Option<measureme::TimingGuard<'a, SerializationSink>>); impl<'a> TimingGuard<'a> { #[inline] @@ -316,14 +312,10 @@ impl<'a> TimingGuard<'a> { ) -> TimingGuard<'a> { let thread_id = thread_id_to_u64(std::thread::current().id()); let raw_profiler = &profiler.profiler; - raw_profiler.record_event(event_kind, event_id, thread_id, TimestampKind::Start); - - TimingGuard(Some(TimingGuardInternal { - raw_profiler, - event_kind, - event_id, - thread_id, - })) + let timing_guard = raw_profiler.start_recording_interval_event(event_kind, + event_id, + thread_id); + TimingGuard(Some(timing_guard)) } #[inline] @@ -331,15 +323,3 @@ impl<'a> TimingGuard<'a> { TimingGuard(None) } } - -impl<'a> Drop for TimingGuardInternal<'a> { - #[inline] - fn drop(&mut self) { - self.raw_profiler.record_event( - self.event_kind, - self.event_id, - self.thread_id, - TimestampKind::End - ); - } -} |
