@@ -162,6 +162,23 @@ void msleep(uint64_t t)
mspin_sleep(t);
}
+unsigned long cycles2nsec(uint64_t cycles)
+{
+ return scale_delta(cycles,
+ shared_info.vcpu_info[0].time.tsc_to_system_mul,
+ shared_info.vcpu_info[0].time.tsc_shift);
+}
+
+unsigned long cycles2usec(uint64_t cycles)
+{
+ return cycles2nsec(cycles) / 1000;
+}
+
+unsigned long cycles2msec(uint64_t cycles)
+{
+ return cycles2nsec(cycles) / 1000000;
+}
+
/*
* Local variables:
* mode: C
@@ -43,10 +43,13 @@ void msleep(uint64_t f);
int gettimeofday(struct timeval *tp);
-
/* This returns the current epoch time */
#define NOW() current_time()
+unsigned long cycles2nsec(uint64_t cycles);
+unsigned long cycles2usec(uint64_t cycles);
+unsigned long cycles2msec(uint64_t cycles);
+
#endif /* XTF_TIME_H */
/*
In order to easily translate CPU cycles to time values add the following helpers: - cycles2nsec() - cycles2usec() - cycles2msec() Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de> --- common/time.c | 17 +++++++++++++++++ include/xtf/time.h | 5 ++++- 2 files changed, 21 insertions(+), 1 deletion(-)