5 #ifndef __UTILS_MONO_TIME_H__
6 #define __UTILS_MONO_TIME_H__
8 #include <mono/utils/mono-compiler.h>
10 #ifdef HAVE_SYS_TIME_H
14 /* Returns the number of milliseconds from boot time: this should be monotonic
16 * Prefer to use mono_msec_ticks for elapsed time calculation. */
17 gint64
mono_msec_boottime (void);
19 /* Returns the number of milliseconds ticks from unspecified time: this should be monotonic */
20 gint64
mono_msec_ticks (void);
22 /* Returns the number of 100ns ticks from unspecified time: this should be monotonic */
23 gint64
mono_100ns_ticks (void);
25 /* Returns the number of 100ns ticks since 1/1/1601, UTC timezone */
26 gint64
mono_100ns_datetime (void);
29 gint64
mono_100ns_datetime_from_timeval (struct timeval tv
);
32 /* Stopwatch class for internal runtime use */
38 mono_stopwatch_start (MonoStopwatch
*w
)
40 w
->start
= mono_100ns_ticks ();
45 mono_stopwatch_stop (MonoStopwatch
*w
)
47 w
->stop
= mono_100ns_ticks ();
51 mono_stopwatch_elapsed (MonoStopwatch
*w
)
53 return (w
->stop
- w
->start
) / 10;
57 mono_stopwatch_elapsed_ms (MonoStopwatch
*w
)
59 return (mono_stopwatch_elapsed (w
) + 500) / 1000;
62 // Expand non-portable strftime shorthands.
63 #define MONO_STRFTIME_F "%Y-%m-%d" // %F in some systems, but this works on all.
64 #define MONO_STRFTIME_T "%H:%M:%S" // %T in some systems, but this works on all.
66 #endif /* __UTILS_MONO_TIME_H__ */