#include <stdio.h>
#include <threads.h>
int time_consuming(void* thr_data) {
double d = 0;
for (int i = 0; i < 10000; i++) {
for (int j = 0; j < 10000; j++) {
d += d * i * j;
}
}
return 0;
}
int main(void)
{
clock_t t1 = clock();
thrd_t thr;
thrd_create(&thr, time_consuming, NULL);
thrd_join(thr, NULL);
clock_t t2 = clock();
double CPUtime = 1000.0 * (t2 - t1) / CLOCKS_PER_SEC;
printf("CPU time used per clock(): %.2f ms\n", CPUtime);
}
/*
run:
CPU time used per clock(): 513.24 ms
*/