I am trying to write a benchmark program that takes about 20 minutes to complete because the actual functions need to be called at least 50 times.
我使用了以下法典:
struct timeval start, end;
long mtime, seconds, useconds;
gettimeofday(&start, NULL);
usleep(2000);
gettimeofday(&end,NULL);
seconds =end.tv_sec - start.tv_sec;
useconds=end.tv_usec - start.tv_usec;
(mtime>1000)?cout<<"elapsed time in seconds:"<<setprecision(8)<<mtime/1000<<"seconds
":cout<<"elapsed time in milliseconds: "<<setprecision(3)<<mtime<<" milliseconds
";
但我必须写这封信,使产出产生最佳单位,用于过去的时间,并在这些单位展示成果。 我如何根据要求修订上述准则? th!