@@ -14,9 +14,12 @@ use measureme::{StringId, TimestampKind};
14
14
/// MmapSerializatioSink is faster on macOS and Linux
15
15
/// but FileSerializationSink is faster on Windows
16
16
#[ cfg( not( windows) ) ]
17
- type Profiler = measureme:: Profiler < measureme :: MmapSerializationSink > ;
17
+ type SerializationSink = measureme:: MmapSerializationSink ;
18
18
#[ cfg( windows) ]
19
- type Profiler = measureme:: Profiler < measureme:: FileSerializationSink > ;
19
+ type SerializationSink = measureme:: FileSerializationSink ;
20
+
21
+ type Profiler = measureme:: Profiler < SerializationSink > ;
22
+
20
23
21
24
#[ derive( Clone , Copy , Debug , PartialEq , Eq , Ord , PartialOrd ) ]
22
25
pub enum ProfileCategory {
@@ -298,14 +301,7 @@ impl SelfProfiler {
298
301
}
299
302
300
303
#[ 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 > > ) ;
309
305
310
306
impl < ' a > TimingGuard < ' a > {
311
307
#[ inline]
@@ -316,30 +312,14 @@ impl<'a> TimingGuard<'a> {
316
312
) -> TimingGuard < ' a > {
317
313
let thread_id = thread_id_to_u64 ( std:: thread:: current ( ) . id ( ) ) ;
318
314
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) )
327
319
}
328
320
329
321
#[ inline]
330
322
pub fn none ( ) -> TimingGuard < ' a > {
331
323
TimingGuard ( None )
332
324
}
333
325
}
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