Code
if(isClient)
{
if(!b)
{
t=clock();
b=true;
}
nowTime=clock();
all+=(sock->reads.size)*0.7;
if((nowTime-t)>1000)
{
double fall=all;
double avg=fall/(nowTime-t);
printf("avg=%f,%f,%f\n",avg,fall,(nowTime-t)/1000.0);
all=0;
if(avg>lim)
{
t=clock();
Sleep(1000*(avg-lim)/lim);
}
else
t=clock();
}
}
出处:http://topic.csdn.net/u/20090424/17/8a732a9e-9f8e-46c5-a8b6-9dfcf903eb86.html?43395