All pastes #838104 Raw Edit

clock_test.c

public text v1 · immutable
#838104 ·published 2007-12-30 03:15 UTC
rendered paste body
#include <stdio.h>
#include <time.h>
#include <math.h>

int main(void)
{
    clock_t before, after;

    before = clock();
    while ((after = clock()) == before) {
        double d = sin(time(NULL));
    }
    printf("before = %f\n", (double)before);
    printf("after  = %f\n", (double)after);
    printf("CLOCKS_PER_SEC = %f\n", (double)CLOCKS_PER_SEC);
    return 0;
}
[vikky@server estimator]$ gcc kst.c -Wall -lm
kst.c: In function ‘main’:
kst.c:11: warning: unused variable ‘d’
[vikky@server estimator]$ ./a.out 
before = 0.000000
after  = 10000.000000
CLOCKS_PER_SEC = 1000000.000000