diff options
author | imarom <imarom@cisco.com> | 2016-08-18 13:49:59 +0300 |
---|---|---|
committer | imarom <imarom@cisco.com> | 2016-08-18 13:52:49 +0300 |
commit | b8353aa9eb017f66166da9ee03ad7cd09abda175 (patch) | |
tree | 416cd03e701fdb2209034d04ea37bdc8a21bf3f4 /src/os_time.h | |
parent | 5f530a21aa669b4ddc0f8d0329794d0c439f6879 (diff) |
CPU util. measurements fix (more accurate and steady)
see #trex-246
Diffstat (limited to 'src/os_time.h')
-rwxr-xr-x | src/os_time.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/os_time.h b/src/os_time.h index b1d44c03..4f10e2b5 100755 --- a/src/os_time.h +++ b/src/os_time.h @@ -165,6 +165,17 @@ void delay(int msec){ nanosleep(&time1,&remain); } - +/** + * more accurate sleep by doing spin + * + */ +static inline +void delay_spin(double sec) { + double target = now_sec() + sec; + + while (now_sec() < target) { + rte_pause(); + } +} #endif |