69,371
社区成员
发帖
与我相关
我的任务
分享
cs$ time ./a.out
real 0m0.003s
user 0m0.000s
sys 0m0.000s
#include <stdio.h>
#include <time.h> /* for time() */
#include <Windows.h> /* for Sleep() */
void test(int sec)
{
Sleep(1000 * sec);
}
int main(int argc,char **argv)
{
time_t t1, t2, run_time;
time(&t1);
test(6);
time(&t2);
run_time = t2 - t1;
printf("%d\n", (int)run_time);
return 0;
}
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
clock_t cBegin = clock();
// do something...
clock_t cEnd = clock();
printf("execution time: %d s", (cEnd - cBegin) / CLOCKS_PER_SEC);
return 0;
}
#include "stdafx.h"
#include "omp.h"
#include <stdlib.h>
int main (int argc, char *argv[])
{
double starttime, stoptime;
starttime = omp_get_wtime();
/*实际程序*/
stoptime = omp_get_wtime();
printf("Time for this routine: %3.2f\n", stoptime-starttime);
}