vendored-meson/meson/test cases/common/91 benchmark/delayer.c
raw| 1 | /* Simple prog that sleeps for a random time. */ |
| 2 | |
| 3 | #include<stdlib.h> |
| 4 | #include<time.h> |
| 5 | #if defined(_WIN32) |
| 6 | #include<windows.h> |
| 7 | #endif |
| 8 | |
| 9 | int main(void) { |
| 10 | srand(time(NULL)); |
| 11 | #if !defined(_WIN32) |
| 12 | struct timespec t; |
| 13 | t.tv_sec = 0; |
| 14 | t.tv_nsec = 199999999.0*rand()/RAND_MAX; |
| 15 | nanosleep(&t, NULL); |
| 16 | #else |
| 17 | Sleep(50.0*rand()/RAND_MAX); |
| 18 | #endif |
| 19 | return 0; |
| 20 | } |