15 #ifdef MOZ_PERF_METRICS
16 # define NS_RESET_AND_START_STOPWATCH(_sw) \
19 # define NS_START_STOPWATCH(_sw) \
22 # define NS_STOP_STOPWATCH(_sw) \
25 # define NS_SAVE_STOPWATCH_STATE(_sw) \
28 # define NS_RESTORE_STOPWATCH_STATE(_sw) \
32 # define NS_RESET_AND_START_STOPWATCH(_sw)
33 # define NS_START_STOPWATCH(_sw)
34 # define NS_STOP_STOPWATCH(_sw)
35 # define NS_SAVE_STOPWATCH_STATE(_sw)
36 # define NS_RESTORE_STOPWATCH_STATE(_sw)
40 #ifdef MOZ_PERF_METRICS
42 static PRLogModuleInfo
* gLogStopwatchModule
= PR_NewLogModule("timing");
45 #define RAPTOR_TRACE_STOPWATCHES 0x1
47 #define RAPTOR_STOPWATCH_TRACE(_args) \
49 PR_LOG(gLogStopwatchModule, RAPTOR_TRACE_STOPWATCHES, _args); \
53 #define RAPTOR_STOPWATCH_TRACE(_args) \
59 #define RAPTOR_TRACE_STOPWATCHES
60 #define RAPTOR_STOPWATCH_TRACE(_args)
63 #ifdef DEBUG_STOPWATCH
64 #define RAPTOR_STOPWATCH_DEBUGTRACE(_args) \
69 #define RAPTOR_STOPWATCH_DEBUGTRACE(_args)
75 enum EState
{ kUndefined
, kStopped
, kRunning
};
77 double fStartRealTime
; //wall clock start time
78 double fStopRealTime
; //wall clock stop time
79 double fStartCpuTime
; //cpu start time
80 double fStopCpuTime
; //cpu stop time
81 double fTotalCpuTime
; //total cpu time
82 double fTotalRealTime
; //total real time
83 EState fState
; //stopwatch state
84 nsDeque
* mSavedStates
; //stack of saved states
85 PRBool mCreatedStack
; //Initially false. Set to true in first SaveState() call.
91 void Start(PRBool reset
= PR_TRUE
);
94 void SaveState(); // record current state of stopwatch
95 void RestoreState(); // restore last recored state of stopwatch
97 double RealTimeInMilliseconds();
98 void Reset() { ResetCpuTime(); ResetRealTime(); }
99 void ResetCpuTime(double aTime
= 0) { Stop(); fTotalCpuTime
= aTime
; }
100 void ResetRealTime(double aTime
= 0) { Stop(); fTotalRealTime
= aTime
; }
103 static double GetRealTime();
104 static double GetCPUTime();