本文整理汇总了C++中Timestamp::subSec方法的典型用法代码示例。如果您正苦于以下问题:C++ Timestamp::subSec方法的具体用法?C++ Timestamp::subSec怎么用?C++ Timestamp::subSec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timestamp
的用法示例。
在下文中一共展示了Timestamp::subSec方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Client_Recv_TCP
void PerfSocket::Client_Recv_TCP(void) {
// terminate loop nicely on user interupts
sInterupted = false;
//my_signal( SIGINT, Sig_Interupt );
//my_signal( SIGPIPE, Sig_Interupt );
#ifndef WIN32
signal (SIGPIPE, SIG_IGN);
#endif
int currLen;
InitTransfer();
double fract = 0.0;
mStartTime.setnow();
long endSize = get_tcp_windowsize(mSock), startSize=endSize, loopLen =0, prevLen =0;
Timestamp prevTime;
prevTime.setnow();
/* Periodic reporting is done here in the loop itself, if Suggest Window Size option is set*/
mPReporting = false;
/* Send the first packet indicating that the server has to send data */
mBuf[0] = 'a';
currLen = write( mSock, mBuf, mSettings->mBufLen );
if ( currLen < 0 ) {
WARN_errno( currLen < 0, "write" );
return;
}
do {
// perform read
currLen = read( mSock, mBuf, mSettings->mBufLen );
mPacketTime.setnow();
if ( currLen < 0 ) {
WARN_errno( currLen < 0, "read" );
break;
}
mTotalLen += currLen;
loopLen +=currLen;
// periodically report bandwidths
ReportPeriodicBW();
double nFract = mStartTime.fraction(mPacketTime,mEndTime);
if ( nFract > (fract + 0.1) ) {
printf(seperator_line);
ReportWindowSize();
sReporting.Lock();
ReportBW( loopLen, prevTime.subSec(mStartTime), mPacketTime.subSec( mStartTime));
sReporting.Unlock();
fract +=0.1;
if ( startSize != endSize ) {
/* Change the window size only if the data transfer has changed at least by 5% */
if ( loopLen < prevLen ) {
if ( ( ((double)(prevLen - loopLen)) /
((double)prevLen)) > 0.05
) {
endSize = startSize + (endSize - startSize)/2;
}
} else {
if ( ( ((double)(loopLen - prevLen)) /
((double)prevLen) ) > 0.05
) {
startSize = endSize;
endSize = endSize*2;
prevLen = loopLen;
}
}
} else {
endSize = endSize*2;
prevLen = loopLen;
}
/** Reset the variables after setting new window size */
prevTime.setnow();
loopLen = 0 ;
//shutdown(mSock,SHUT_RDWR);
close(mSock);
mSock = -1;
Connect( mSettings->mHost, mSettings->mLocalhost );
mBuf[0] = 'a';
if ( set_tcp_windowsize(mSock,endSize) == -1 ) {
printf(unable_to_change_win);
}
if ( get_tcp_windowsize(mSock) != endSize ) {
printf(unable_to_change_win);
}
write( mSock, mBuf, mSettings->mBufLen );
}
} while ( ! (sInterupted ||
(mMode_time && mPacketTime.after( mEndTime )) ||
(!mMode_time && mTotalLen >= mAmount))
);
//.........这里部分代码省略.........