@@ -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 ) ]
2225pub 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
310306impl < ' 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