mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-26 06:35:27 +00:00
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]]
|
||||
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",
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user