add sigar_time_now_millis util

This commit is contained in:
Doug MacEachern 2008-03-16 19:19:35 +00:00
parent 1283315dfc
commit 15f7996b8a
3 changed files with 13 additions and 0 deletions

View File

@ -117,6 +117,7 @@
#endif
#define SIGAR_MSEC 1000L
#define SIGAR_USEC 1000000L
#define SIGAR_NSEC 1000000000L
#define SIGAR_SEC2NANO(s) \

View File

@ -62,6 +62,8 @@
#define PROCP_FS_ROOT "/proc/"
#endif
sigar_int64_t sigar_time_now_millis(void);
char *sigar_uitoa(char *buf, unsigned int n, int *len);
int sigar_inet_ntoa(sigar_t *sigar,

View File

@ -812,3 +812,13 @@ SIGAR_DECLARE(void) sigar_log_impl_file(sigar_t *sigar, void *data,
FILE *fp = (FILE*)data;
fprintf(fp, "[%s] %s\n", log_levels[level], message);
}
sigar_int64_t sigar_time_now_millis(void)
{
#ifdef WIN32
#else
struct timeval tv;
gettimeofday(&tv, NULL);
return ((tv.tv_sec * SIGAR_USEC) + tv.tv_usec) / SIGAR_MSEC;
#endif
}