self-profiling: Update measureme to 0.4.0 and use new RAII-based API.
This commit is contained in:
parent
f6aa64b7b0
commit
ee1173a8ff
|
@ -1954,9 +1954,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "measureme"
|
name = "measureme"
|
||||||
version = "0.3.0"
|
version = "0.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d09de7dafa3aa334bc806447c7e4de69419723312f4b88b80b561dea66601ce8"
|
checksum = "cd21b0e6e1af976b269ce062038fe5e1b9ca2f817ab7a3af09ec4210aebf0d30"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"memmap",
|
"memmap",
|
||||||
|
|
|
@ -37,4 +37,4 @@ byteorder = { version = "1.3" }
|
||||||
chalk-engine = { version = "0.9.0", default-features=false }
|
chalk-engine = { version = "0.9.0", default-features=false }
|
||||||
rustc_fs_util = { path = "../librustc_fs_util" }
|
rustc_fs_util = { path = "../librustc_fs_util" }
|
||||||
smallvec = { version = "0.6.8", features = ["union", "may_dangle"] }
|
smallvec = { version = "0.6.8", features = ["union", "may_dangle"] }
|
||||||
measureme = "0.3"
|
measureme = "0.4"
|
||||||
|
|
|
@ -14,9 +14,12 @@ use measureme::{StringId, TimestampKind};
|
||||||
/// MmapSerializatioSink is faster on macOS and Linux
|
/// MmapSerializatioSink is faster on macOS and Linux
|
||||||
/// but FileSerializationSink is faster on Windows
|
/// but FileSerializationSink is faster on Windows
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
type Profiler = measureme::Profiler<measureme::MmapSerializationSink>;
|
type SerializationSink = measureme::MmapSerializationSink;
|
||||||
#[cfg(windows)]
|
#[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)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Ord, PartialOrd)]
|
||||||
pub enum ProfileCategory {
|
pub enum ProfileCategory {
|
||||||
|
@ -298,14 +301,7 @@ impl SelfProfiler {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub struct TimingGuard<'a>(Option<TimingGuardInternal<'a>>);
|
pub struct TimingGuard<'a>(Option<measureme::TimingGuard<'a, SerializationSink>>);
|
||||||
|
|
||||||
struct TimingGuardInternal<'a> {
|
|
||||||
raw_profiler: &'a Profiler,
|
|
||||||
event_id: StringId,
|
|
||||||
event_kind: StringId,
|
|
||||||
thread_id: u64,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> TimingGuard<'a> {
|
impl<'a> TimingGuard<'a> {
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -316,14 +312,10 @@ impl<'a> TimingGuard<'a> {
|
||||||
) -> TimingGuard<'a> {
|
) -> TimingGuard<'a> {
|
||||||
let thread_id = thread_id_to_u64(std::thread::current().id());
|
let thread_id = thread_id_to_u64(std::thread::current().id());
|
||||||
let raw_profiler = &profiler.profiler;
|
let raw_profiler = &profiler.profiler;
|
||||||
raw_profiler.record_event(event_kind, event_id, thread_id, TimestampKind::Start);
|
let timing_guard = raw_profiler.start_recording_interval_event(event_kind,
|
||||||
|
event_id,
|
||||||
TimingGuard(Some(TimingGuardInternal {
|
thread_id);
|
||||||
raw_profiler,
|
TimingGuard(Some(timing_guard))
|
||||||
event_kind,
|
|
||||||
event_id,
|
|
||||||
thread_id,
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -331,15 +323,3 @@ impl<'a> TimingGuard<'a> {
|
||||||
TimingGuard(None)
|
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
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue