summaryrefslogtreecommitdiffstats
path: root/test cases/common/91 benchmark/delayer.c
blob: b410c460511ac14b4f3ef81749c836c917d08447 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* Simple prog that sleeps for a random time. */

#include<stdlib.h>
#include<time.h>
#if defined(_WIN32)
#include<windows.h>
#endif

int main(void) {
    srand(time(NULL));
#if !defined(_WIN32)
    struct timespec t;
    t.tv_sec = 0;
    t.tv_nsec = 199999999.0*rand()/RAND_MAX;
    nanosleep(&t, NULL);
#else
    Sleep(50.0*rand()/RAND_MAX);
#endif
    return 0;
}