* Busy wait for a given number of microseconds. * Callers should use this method in most reasonable cases as opposed to * usleep for accurate measurements. Calling usleep may put the the processor * in a low power mode/sleep state which reduces the clock frequency. * So, each time the process/thread wakes up from usleep, it takes some time * to ramp up to maximum frequency. Thus meausrements
| 218 | * Number of microseconds. |
| 219 | */ |
| 220 | void |
| 221 | Cycles::sleep(uint64_t us) |
| 222 | { |
| 223 | uint64_t stop = Cycles::rdtsc() + Cycles::fromNanoseconds(1000*us); |
| 224 | while (Cycles::rdtsc() < stop); |
| 225 | } |
| 226 | } // end PerfUtils |