util: add func to return time as uint64 microseconds
authorKeith Whitwell <keith@tungstengraphics.com>
Mon, 1 Sep 2008 13:23:47 +0000 (14:23 +0100)
committerKeith Whitwell <keith@tungstengraphics.com>
Mon, 1 Sep 2008 13:24:33 +0000 (14:24 +0100)
src/gallium/auxiliary/util/u_time.c
src/gallium/auxiliary/util/u_time.h

index 49dce75289591e6d99b861b84c231f5de64422c8..bf7d1d1c8d5423c3f6fa22d66eff00d06bb43c4a 100644 (file)
@@ -136,6 +136,26 @@ util_time_diff(const struct util_time *t1,
 }
 
 
+
+uint64_t
+util_time_micros( void )
+{
+   struct util_time t1;
+   
+   util_time_get(&t1);
+   
+#if defined(PIPE_OS_LINUX)
+   return t1.tv.tv_usec + t1.tv.tv_sec*1000000LL;
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) || defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_SUBSYSTEM_WINDOWS_CE)
+   util_time_get_frequency();
+   return t1.counter*INT64_C(1000000)/frequency;
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
+   return t1.counter/10;
+#endif
+}
+
+
+
 /**
  * Compare two time values.
  * 
index f9963ce0e27b1b7647d8911fd41367205d714604..35d97d16c739758674fd3f18eeb0224e5a8fecb4 100644 (file)
@@ -74,6 +74,9 @@ util_time_add(const struct util_time *t1,
               int64_t usecs,
               struct util_time *t2);
 
+uint64_t
+util_time_micros( void );
+
 int64_t
 util_time_diff(const struct util_time *t1, 
                const struct util_time *t2);