|
发表于 2009-11-2 05:04:03
|
显示全部楼层
IP:江苏扬州
你用的50000值太小了,计算滴答数又不正确.
clock函数告诉调用进程用了多少处理器时间,
秒时间是时钟返回值除以该常量值的近似值
.换句话说,clock返回值为已经消逝的处理器时钟滴答数,
一个时钟滴答数近似等于1/CLOCKSPERSEC
秒.
#include <time.h>
#include <stdio.h>
#include <dos.h>
#include <conio.h>
#include <windows.h>
#include <windowsx.h>
#include <fstream.h>
#include <iostream.h>
int main(void)
{int i,j;
int wrh,v,s=1500;
clock_t start,end;
double duration;
start=clock();
cout<<start<<"\n";
for(i=0;i<50000000;i++)
{j+1;j-1;}
end=clock();
duration=(double)(end-start)/CLOCKS_PER_SEC;
cout<<duration<<"\n";
getch();
} |
|