Merge remote-tracking branch 'lp-Com/use-monotonic' into 7.0
* lp-Com/use-monotonic: VxWorks: Measure CPU time-base frequency if necessary replace most internal getCurrent() -> getMonotonic() dbScan periodic scan use monotonic time monotonic adapt to regular time APIs
This commit is contained in:
@@ -83,7 +83,7 @@ int CASG::block (
|
||||
return ECA_TIMEOUT;
|
||||
}
|
||||
|
||||
cur_time = epicsTime::getCurrent ();
|
||||
cur_time = epicsTime::getMonotonic ();
|
||||
|
||||
this->client.flush ( guard );
|
||||
|
||||
@@ -121,7 +121,7 @@ int CASG::block (
|
||||
/*
|
||||
* force a time update
|
||||
*/
|
||||
cur_time = epicsTime::getCurrent ();
|
||||
cur_time = epicsTime::getMonotonic ();
|
||||
|
||||
delay = cur_time - beg_time;
|
||||
}
|
||||
|
||||
@@ -475,7 +475,7 @@ int ca_client_context::pendIO ( const double & timeout )
|
||||
}
|
||||
|
||||
int status = ECA_NORMAL;
|
||||
epicsTime beg_time = epicsTime::getCurrent ();
|
||||
epicsTime beg_time = epicsTime::getMonotonic ();
|
||||
double remaining = timeout;
|
||||
|
||||
epicsGuard < epicsMutex > guard ( this->mutex );
|
||||
@@ -493,7 +493,7 @@ int ca_client_context::pendIO ( const double & timeout )
|
||||
this->blockForEventAndEnableCallbacks ( this->ioDone, remaining );
|
||||
}
|
||||
|
||||
double delay = epicsTime::getCurrent () - beg_time;
|
||||
double delay = epicsTime::getMonotonic () - beg_time;
|
||||
if ( delay < timeout ) {
|
||||
remaining = timeout - delay;
|
||||
}
|
||||
@@ -522,7 +522,7 @@ int ca_client_context::pendEvent ( const double & timeout )
|
||||
return ECA_EVDISALLOW;
|
||||
}
|
||||
|
||||
epicsTime current = epicsTime::getCurrent ();
|
||||
epicsTime current = epicsTime::getMonotonic ();
|
||||
|
||||
{
|
||||
epicsGuard < epicsMutex > guard ( this->mutex );
|
||||
@@ -563,7 +563,7 @@ int ca_client_context::pendEvent ( const double & timeout )
|
||||
this->noWakeupSincePend = true;
|
||||
}
|
||||
|
||||
double elapsed = epicsTime::getCurrent() - current;
|
||||
double elapsed = epicsTime::getMonotonic() - current;
|
||||
double delay;
|
||||
|
||||
if ( timeout > elapsed ) {
|
||||
|
||||
@@ -130,7 +130,7 @@ cac::cac (
|
||||
epicsMutex & callbackControlIn,
|
||||
cacContextNotify & notifyIn ) :
|
||||
_refLocalHostName ( localHostNameCache.getReference () ),
|
||||
programBeginTime ( epicsTime::getCurrent() ),
|
||||
programBeginTime ( epicsTime::getMonotonic() ),
|
||||
connTMO ( CA_CONN_VERIFY_PERIOD ),
|
||||
mutex ( mutualExclusionIn ),
|
||||
cbMutex ( callbackControlIn ),
|
||||
|
||||
@@ -59,7 +59,7 @@ int main ( int argc, char ** argv )
|
||||
epicsMutex mutex;
|
||||
epicsGuard < epicsMutex > guard ( mutex );
|
||||
bheFreeStoreMgr bheFreeList;
|
||||
epicsTime programBeginTime = epicsTime::getCurrent ();
|
||||
epicsTime programBeginTime = epicsTime::getMonotonic ();
|
||||
bool validCommandLine = false;
|
||||
unsigned interest = 0u;
|
||||
SOCKET sock;
|
||||
@@ -244,7 +244,7 @@ int main ( int argc, char ** argv )
|
||||
ca_uint32_t beaconNumber = ntohl ( pCurMsg->m_cid );
|
||||
unsigned protocolRevision = ntohs ( pCurMsg->m_dataType );
|
||||
|
||||
epicsTime currentTime = epicsTime::getCurrent();
|
||||
epicsTime currentTime = epicsTime::getMonotonic();
|
||||
|
||||
/*
|
||||
* look for it in the hash table
|
||||
|
||||
@@ -43,7 +43,7 @@ searchTimer::searchTimer (
|
||||
const unsigned indexIn,
|
||||
epicsMutex & mutexIn,
|
||||
bool boostPossibleIn ) :
|
||||
timeAtLastSend ( epicsTime::getCurrent () ),
|
||||
timeAtLastSend ( epicsTime::getMonotonic () ),
|
||||
timer ( queueIn.createTimer () ),
|
||||
iiu ( iiuIn ),
|
||||
mutex ( mutexIn ),
|
||||
|
||||
@@ -476,7 +476,7 @@ void tcpRecvThread::run ()
|
||||
statusWireIO stat;
|
||||
pComBuf->fillFromWire ( this->iiu, stat );
|
||||
|
||||
epicsTime currentTime = epicsTime::getCurrent ();
|
||||
epicsTime currentTime = epicsTime::getMonotonic ();
|
||||
|
||||
{
|
||||
epicsGuard < epicsMutex > guard ( this->iiu.mutex );
|
||||
@@ -1669,7 +1669,7 @@ bool tcpiiu::sendThreadFlush ( epicsGuard < epicsMutex > & guard )
|
||||
|
||||
if ( this->sendQue.occupiedBytes() > 0 ) {
|
||||
while ( comBuf * pBuf = this->sendQue.popNextComBufToSend () ) {
|
||||
epicsTime current = epicsTime::getCurrent ();
|
||||
epicsTime current = epicsTime::getMonotonic ();
|
||||
|
||||
unsigned bytesToBeSent = pBuf->occupiedBytes ();
|
||||
bool success = false;
|
||||
|
||||
@@ -435,7 +435,7 @@ void udpRecvThread::run ()
|
||||
}
|
||||
else if ( status > 0 ) {
|
||||
this->iiu.postMsg ( src, this->iiu.recvBuf,
|
||||
(arrayElementCount) status, epicsTime::getCurrent() );
|
||||
(arrayElementCount) status, epicsTime::getMonotonic() );
|
||||
}
|
||||
|
||||
} while ( ! this->iiu.shutdownCmd );
|
||||
|
||||
@@ -144,12 +144,12 @@ void dbPutNotifyBlocker::initiatePutNotify (
|
||||
break;
|
||||
}
|
||||
if ( beginTimeInit ) {
|
||||
if ( epicsTime::getCurrent () - begin > 30.0 ) {
|
||||
if ( epicsTime::getMonotonic () - begin > 30.0 ) {
|
||||
throw cacChannel::requestTimedOut ();
|
||||
}
|
||||
}
|
||||
else {
|
||||
begin = epicsTime::getCurrent ();
|
||||
begin = epicsTime::getMonotonic ();
|
||||
beginTimeInit = true;
|
||||
}
|
||||
{
|
||||
|
||||
@@ -787,7 +787,7 @@ static void periodicTask(void *arg)
|
||||
taskwdInsert(0, NULL, NULL);
|
||||
epicsEventSignal(startStopEvent);
|
||||
|
||||
epicsTimeGetCurrent(&next);
|
||||
epicsTimeGetMonotonic(&next);
|
||||
reported = next;
|
||||
|
||||
while (ppsl->scanCtl != ctlExit) {
|
||||
@@ -798,7 +798,7 @@ static void periodicTask(void *arg)
|
||||
scanList(&ppsl->scan_list);
|
||||
|
||||
epicsTimeAddSeconds(&next, ppsl->period);
|
||||
epicsTimeGetCurrent(&now);
|
||||
epicsTimeGetMonotonic(&now);
|
||||
delay = epicsTimeDiffInSeconds(&next, &now);
|
||||
if (delay <= 0.0) {
|
||||
if (overtime == 0.0) {
|
||||
|
||||
@@ -97,7 +97,7 @@ epicsShareFunc void fdManager::process (double delay)
|
||||
// more than once here so that fd activity get serviced
|
||||
// in a reasonable length of time.
|
||||
//
|
||||
double minDelay = this->pTimerQueue->process(epicsTime::getCurrent());
|
||||
double minDelay = this->pTimerQueue->process(epicsTime::getMonotonic());
|
||||
|
||||
if ( minDelay >= delay ) {
|
||||
minDelay = delay;
|
||||
@@ -121,7 +121,7 @@ epicsShareFunc void fdManager::process (double delay)
|
||||
fd_set * pExceptSet = & this->fdSetsPtr[fdrException];
|
||||
int status = select (this->maxFD, pReadSet, pWriteSet, pExceptSet, &tv);
|
||||
|
||||
this->pTimerQueue->process(epicsTime::getCurrent());
|
||||
this->pTimerQueue->process(epicsTime::getMonotonic());
|
||||
|
||||
if ( status > 0 ) {
|
||||
|
||||
@@ -204,7 +204,7 @@ epicsShareFunc void fdManager::process (double delay)
|
||||
* of select()
|
||||
*/
|
||||
epicsThreadSleep(minDelay);
|
||||
this->pTimerQueue->process(epicsTime::getCurrent());
|
||||
this->pTimerQueue->process(epicsTime::getMonotonic());
|
||||
}
|
||||
this->processInProg = false;
|
||||
return;
|
||||
|
||||
@@ -215,6 +215,14 @@ int epicsShareAPI epicsTimeGetCurrent(epicsTimeStamp *pDest)
|
||||
return status;
|
||||
}
|
||||
|
||||
int epicsTimeGetMonotonic ( epicsTimeStamp * pDest )
|
||||
{
|
||||
epicsUInt64 now = epicsMonotonicGet();
|
||||
pDest->nsec = now%1000000000ul;
|
||||
pDest->secPastEpoch = now/1000000000ul;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int epicsTimeGetCurrentInt(epicsTimeStamp *pDest)
|
||||
{
|
||||
gtProvider *ptp = gtPvt.lastTimeProvider;
|
||||
|
||||
@@ -164,7 +164,7 @@ bool epicsThread::exitWait ( const double delay ) throw ()
|
||||
}
|
||||
return true;
|
||||
}
|
||||
epicsTime exitWaitBegin = epicsTime::getCurrent ();
|
||||
epicsTime exitWaitBegin = epicsTime::getMonotonic ();
|
||||
double exitWaitElapsed = 0.0;
|
||||
epicsGuard < epicsMutex > guard ( this->mutex );
|
||||
this->cancel = true;
|
||||
@@ -172,7 +172,7 @@ bool epicsThread::exitWait ( const double delay ) throw ()
|
||||
epicsGuardRelease < epicsMutex > unguard ( guard );
|
||||
this->event.signal ();
|
||||
this->exitEvent.wait ( delay - exitWaitElapsed );
|
||||
epicsTime current = epicsTime::getCurrent ();
|
||||
epicsTime current = epicsTime::getMonotonic ();
|
||||
exitWaitElapsed = current - exitWaitBegin;
|
||||
}
|
||||
if(this->terminated && !joined) {
|
||||
|
||||
@@ -215,6 +215,13 @@ epicsTime epicsTime::getCurrent ()
|
||||
return epicsTime ( current );
|
||||
}
|
||||
|
||||
epicsTime epicsTime::getMonotonic()
|
||||
{
|
||||
epicsTimeStamp current;
|
||||
epicsTimeGetMonotonic (¤t); // can't fail
|
||||
return epicsTime ( current );
|
||||
}
|
||||
|
||||
epicsTime epicsTime::getEvent (const epicsTimeEvent &event)
|
||||
{
|
||||
epicsTimeStamp current;
|
||||
|
||||
@@ -85,6 +85,7 @@ public:
|
||||
|
||||
static epicsTime getEvent ( const epicsTimeEvent & );
|
||||
static epicsTime getCurrent ();
|
||||
static epicsTime getMonotonic ();
|
||||
|
||||
/* convert to and from EPICS epicsTimeStamp format */
|
||||
operator epicsTimeStamp () const;
|
||||
@@ -191,6 +192,7 @@ extern "C" {
|
||||
epicsShareFunc int epicsShareAPI epicsTimeGetCurrent ( epicsTimeStamp * pDest );
|
||||
epicsShareFunc int epicsShareAPI epicsTimeGetEvent (
|
||||
epicsTimeStamp *pDest, int eventNumber);
|
||||
epicsShareFunc int epicsTimeGetMonotonic ( epicsTimeStamp * pDest );
|
||||
|
||||
/* These are callable from an Interrupt Service Routine */
|
||||
epicsShareFunc int epicsTimeGetCurrentInt(epicsTimeStamp *pDest);
|
||||
|
||||
@@ -9,10 +9,13 @@
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <stdio.h>
|
||||
#include <sysLib.h>
|
||||
#include <taskLib.h>
|
||||
|
||||
#define EPICS_EXPOSE_LIBCOM_MONOTONIC_PRIVATE
|
||||
#include "epicsTypes.h"
|
||||
#include "epicsTime.h"
|
||||
#include "cantProceed.h"
|
||||
|
||||
|
||||
#define NS_PER_SEC 1000000000
|
||||
@@ -23,6 +26,7 @@ union timebase {
|
||||
UINT64 u64; /* epicsMonotonicGet() */
|
||||
};
|
||||
|
||||
static void measureTickRate(void);
|
||||
|
||||
#if CPU_FAMILY == PPC
|
||||
#include <arch/ppc/vxPpcLib.h>
|
||||
@@ -46,12 +50,15 @@ void osdMonotonicInit(void)
|
||||
if (sysTimeBaseFreq) {
|
||||
ticksPerSec = sysTimeBaseFreq();
|
||||
|
||||
if (!ticksPerSec)
|
||||
printf("Warning: Failed to set up monotonic time source.\n");
|
||||
/* Warn here only if the BSP routine exists but returned 0 */
|
||||
if (ticksPerSec)
|
||||
return;
|
||||
|
||||
/* This should never happen */
|
||||
printf("Warning: sysTimeBaseFreq() present but returned zero.\n");
|
||||
}
|
||||
else
|
||||
ticksPerSec = 0; /* Warn on first use */
|
||||
|
||||
/* Fall back to measuring */
|
||||
measureTickRate();
|
||||
}
|
||||
|
||||
|
||||
@@ -73,8 +80,14 @@ void osdMonotonicInit(void)
|
||||
{
|
||||
ticksPerSec = vxCpuIdGetFreq();
|
||||
|
||||
if (!ticksPerSec)
|
||||
printf("Warning: Failed to set up monotonic time source.\n");
|
||||
if (ticksPerSec)
|
||||
return;
|
||||
|
||||
/* This should never happen */
|
||||
printf("Warning: vxCpuIdGetFreq() returned zero.\n");
|
||||
|
||||
/* Fall back to measuring */
|
||||
measureTickRate();
|
||||
}
|
||||
|
||||
|
||||
@@ -96,13 +109,7 @@ epicsUInt64 epicsMonotonicGet(void)
|
||||
union timebase tbNow;
|
||||
|
||||
if (!ticksPerSec) {
|
||||
static int warned = 0;
|
||||
|
||||
if (!warned) {
|
||||
printf("Warning: Monotonic time source is not available.\n");
|
||||
warned = 1;
|
||||
}
|
||||
return 0;
|
||||
cantProceed("Monotonic time source not available.\n");
|
||||
}
|
||||
|
||||
TIMEBASEGET(tbNow);
|
||||
@@ -111,3 +118,20 @@ epicsUInt64 epicsMonotonicGet(void)
|
||||
*/
|
||||
return ((long double) tbNow.u64) * NS_PER_SEC / ticksPerSec;
|
||||
}
|
||||
|
||||
static void measureTickRate(void)
|
||||
{
|
||||
union timebase start, end;
|
||||
int sysTicks = sysClkRateGet(); /* 1 second */
|
||||
|
||||
printf("osdMonotonicInit: Measuring CPU time-base frequency ...");
|
||||
fflush(stdout);
|
||||
|
||||
taskDelay(1);
|
||||
TIMEBASEGET(start);
|
||||
taskDelay(sysTicks);
|
||||
TIMEBASEGET(end);
|
||||
ticksPerSec = end.u64 - start.u64;
|
||||
|
||||
printf(" %llu ticks/sec.\n", (unsigned long long) ticksPerSec);
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ extern "C" double epicsShareAPI
|
||||
epicsTimerQueuePassiveProcess ( epicsTimerQueuePassiveId pQueue )
|
||||
{
|
||||
try {
|
||||
return pQueue->process ( epicsTime::getCurrent() );
|
||||
return pQueue->process ( epicsTime::getMonotonic() );
|
||||
}
|
||||
catch ( ... ) {
|
||||
return 1.0;
|
||||
|
||||
@@ -118,7 +118,7 @@ inline double epicsTimer::getExpireDelay ()
|
||||
{
|
||||
epicsTimer::expireInfo info = this->getExpireInfo ();
|
||||
if ( info.active ) {
|
||||
double delay = info.expireTime - epicsTime::getCurrent ();
|
||||
double delay = info.expireTime - epicsTime::getMonotonic ();
|
||||
if ( delay < 0.0 ) {
|
||||
delay = 0.0;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ void timer::destroy ()
|
||||
|
||||
void timer::start ( epicsTimerNotify & notify, double delaySeconds )
|
||||
{
|
||||
this->start ( notify, epicsTime::getCurrent () + delaySeconds );
|
||||
this->start ( notify, epicsTime::getMonotonic () + delaySeconds );
|
||||
}
|
||||
|
||||
void timer::start ( epicsTimerNotify & notify, const epicsTime & expire )
|
||||
@@ -129,7 +129,7 @@ void timer::privateStart ( epicsTimerNotify & notify, const epicsTime & expire )
|
||||
|
||||
debugPrintf ( ("Start of \"%s\" with delay %f at %p preempting %u\n",
|
||||
typeid ( this->notify ).name (),
|
||||
expire - epicsTime::getCurrent (),
|
||||
expire - epicsTime::getMonotonic (),
|
||||
this, preemptCount ) );
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ void timer::show ( unsigned int level ) const
|
||||
double delay;
|
||||
if ( this->curState == statePending || this->curState == stateActive ) {
|
||||
try {
|
||||
delay = this->exp - epicsTime::getCurrent();
|
||||
delay = this->exp - epicsTime::getMonotonic();
|
||||
}
|
||||
catch ( ... ) {
|
||||
delay = - DBL_MAX;
|
||||
|
||||
@@ -30,7 +30,7 @@ timerQueue::timerQueue ( epicsTimerQueueNotify & notifyIn ) :
|
||||
pExpireTmr ( 0 ),
|
||||
processThread ( 0 ),
|
||||
exceptMsgTimeStamp (
|
||||
epicsTime :: getCurrent () - exceptMsgMinPeriod ),
|
||||
epicsTime :: getMonotonic () - exceptMsgMinPeriod ),
|
||||
cancelPending ( false )
|
||||
{
|
||||
}
|
||||
@@ -49,7 +49,7 @@ void timerQueue ::
|
||||
char date[64];
|
||||
double delay;
|
||||
try {
|
||||
epicsTime cur = epicsTime :: getCurrent ();
|
||||
epicsTime cur = epicsTime :: getMonotonic ();
|
||||
delay = cur - this->exceptMsgTimeStamp;
|
||||
cur.strftime ( date, sizeof ( date ),
|
||||
"%a %b %d %Y %H:%M:%S.%f" );
|
||||
|
||||
@@ -73,7 +73,7 @@ void timerQueueActive :: _printLastChanceExceptionMessage (
|
||||
{
|
||||
char date[64];
|
||||
try {
|
||||
epicsTime cur = epicsTime :: getCurrent ();
|
||||
epicsTime cur = epicsTime :: getMonotonic ();
|
||||
cur.strftime ( date, sizeof ( date ), "%a %b %d %Y %H:%M:%S.%f");
|
||||
}
|
||||
catch ( ... ) {
|
||||
@@ -91,7 +91,7 @@ void timerQueueActive :: run ()
|
||||
epics::atomic::set(this->exitFlag, 0);
|
||||
while ( ! this->terminateFlag ) {
|
||||
try {
|
||||
double delay = this->queue.process ( epicsTime::getCurrent() );
|
||||
double delay = this->queue.process ( epicsTime::getMonotonic() );
|
||||
debugPrintf ( ( "timer thread sleeping for %g sec (max)\n", delay ) );
|
||||
this->rescheduleEvent.wait ( delay );
|
||||
}
|
||||
|
||||
@@ -147,11 +147,11 @@ void Perf :: measure (double srcD, float srcF, int prec)
|
||||
|
||||
std::memset(buf, 0, sizeof(buf));
|
||||
|
||||
epicsTime beg = epicsTime :: getCurrent ();
|
||||
epicsTime beg = epicsTime :: getMonotonic ();
|
||||
for ( unsigned i = 0; i < nIterations; i++ ) {
|
||||
c->target (srcD, srcF, buf, sizeof(buf) - 1, prec);
|
||||
}
|
||||
epicsTime end = epicsTime :: getCurrent ();
|
||||
epicsTime end = epicsTime :: getMonotonic ();
|
||||
|
||||
double elapsed = end - beg;
|
||||
elapsed /= nIterations * nUnrolled;
|
||||
|
||||
@@ -394,12 +394,12 @@ static const unsigned N = 10000;
|
||||
void recursiveOwnershipRetPerformance ()
|
||||
{
|
||||
RefCtr refCtr;
|
||||
epicsTime begin = epicsTime::getCurrent ();
|
||||
epicsTime begin = epicsTime::getMonotonic ();
|
||||
for ( size_t i = 0; i < N; i++ ) {
|
||||
Ownership ownership ( refCtr );
|
||||
recurRetOwner1000 ( ownership );
|
||||
}
|
||||
double delay = epicsTime::getCurrent () - begin;
|
||||
double delay = epicsTime::getMonotonic () - begin;
|
||||
delay /= N * 1000u; // convert to delay per call
|
||||
delay *= 1e6; // convert to micro seconds
|
||||
testDiag ( "retOwnership() takes %f microseconds", delay );
|
||||
@@ -408,13 +408,13 @@ void recursiveOwnershipRetPerformance ()
|
||||
void ownershipPassRefPerformance ()
|
||||
{
|
||||
RefCtr refCtr;
|
||||
epicsTime begin = epicsTime::getCurrent ();
|
||||
epicsTime begin = epicsTime::getMonotonic ();
|
||||
for ( size_t i = 0; i < N; i++ ) {
|
||||
Ownership ownershipSrc ( refCtr );
|
||||
Ownership ownershipDest;
|
||||
passRefOwnership1000 ( ownershipSrc, ownershipDest );
|
||||
}
|
||||
double delay = epicsTime::getCurrent () - begin;
|
||||
double delay = epicsTime::getMonotonic () - begin;
|
||||
delay /= N * 1000u; // convert to delay per call
|
||||
delay *= 1e6; // convert to micro seconds
|
||||
testDiag ( "passRefOwnership() takes %f microseconds", delay );
|
||||
@@ -456,7 +456,7 @@ void Ten < T > :: diagnostic ( double delay )
|
||||
template < class T >
|
||||
void measurePerformance ()
|
||||
{
|
||||
epicsTime begin = epicsTime::getCurrent ();
|
||||
epicsTime begin = epicsTime::getMonotonic ();
|
||||
T target;
|
||||
for ( size_t i = 0; i < N; i++ ) {
|
||||
target.run ();
|
||||
@@ -470,7 +470,7 @@ void measurePerformance ()
|
||||
target.run ();
|
||||
target.run ();
|
||||
}
|
||||
double delay = epicsTime::getCurrent () - begin;
|
||||
double delay = epicsTime::getMonotonic () - begin;
|
||||
delay /= ( N * 10u ); // convert to delay per call
|
||||
target.diagnostic ( delay );
|
||||
}
|
||||
|
||||
@@ -156,9 +156,9 @@ static void eventWakeupTest(void)
|
||||
|
||||
static double eventWaitMeasureDelayError( const epicsEventId &id, const double & delay )
|
||||
{
|
||||
epicsTime beg = epicsTime::getCurrent();
|
||||
epicsTime beg = epicsTime::getMonotonic();
|
||||
epicsEventWaitWithTimeout ( id, delay );
|
||||
epicsTime end = epicsTime::getCurrent();
|
||||
epicsTime end = epicsTime::getMonotonic();
|
||||
double meas = end - beg;
|
||||
double error = fabs ( delay - meas );
|
||||
testDiag("epicsEventWaitWithTimeout(%.6f) delay error %.6f sec",
|
||||
|
||||
@@ -168,32 +168,32 @@ void epicsMutexPerformance ()
|
||||
unsigned i;
|
||||
|
||||
// test a single lock pair
|
||||
epicsTime begin = epicsTime::getCurrent ();
|
||||
epicsTime begin = epicsTime::getMonotonic ();
|
||||
static const unsigned N = 1000;
|
||||
for ( i = 0; i < N; i++ ) {
|
||||
tenLockPairsSquared ( mutex );
|
||||
}
|
||||
double delay = epicsTime::getCurrent () - begin;
|
||||
double delay = epicsTime::getMonotonic () - begin;
|
||||
delay /= N * 100u; // convert to delay per lock pair
|
||||
delay *= 1e6; // convert to micro seconds
|
||||
testDiag("lock()*1/unlock()*1 takes %f microseconds", delay);
|
||||
|
||||
// test a two times recursive lock pair
|
||||
begin = epicsTime::getCurrent ();
|
||||
begin = epicsTime::getMonotonic ();
|
||||
for ( i = 0; i < N; i++ ) {
|
||||
tenDoubleRecursiveLockPairsSquared ( mutex );
|
||||
}
|
||||
delay = epicsTime::getCurrent () - begin;
|
||||
delay = epicsTime::getMonotonic () - begin;
|
||||
delay /= N * 100u; // convert to delay per lock pair
|
||||
delay *= 1e6; // convert to micro seconds
|
||||
testDiag("lock()*2/unlock()*2 takes %f microseconds", delay);
|
||||
|
||||
// test a four times recursive lock pair
|
||||
begin = epicsTime::getCurrent ();
|
||||
begin = epicsTime::getMonotonic ();
|
||||
for ( i = 0; i < N; i++ ) {
|
||||
tenQuadRecursiveLockPairsSquared ( mutex );
|
||||
}
|
||||
delay = epicsTime::getCurrent () - begin;
|
||||
delay = epicsTime::getMonotonic () - begin;
|
||||
delay /= N * 100u; // convert to delay per lock pair
|
||||
delay *= 1e6; // convert to micro seconds
|
||||
testDiag("lock()*4/unlock()*4 takes %f microseconds", delay);
|
||||
|
||||
@@ -55,9 +55,9 @@ static void epicsThreadPriorityTest()
|
||||
|
||||
static double threadSleepMeasureDelayError ( const double & delay )
|
||||
{
|
||||
epicsTime beg = epicsTime::getCurrent();
|
||||
epicsTime beg = epicsTime::getMonotonic();
|
||||
epicsThreadSleep ( delay );
|
||||
epicsTime end = epicsTime::getCurrent();
|
||||
epicsTime end = epicsTime::getMonotonic();
|
||||
double meas = end - beg;
|
||||
double error = fabs ( delay - meas );
|
||||
return error;
|
||||
@@ -76,10 +76,10 @@ static double measureSleepQuantum (
|
||||
double interval = rand ();
|
||||
interval /= RAND_MAX;
|
||||
interval *= testInterval;
|
||||
epicsTime start = epicsTime::getCurrent ();
|
||||
epicsTime start = epicsTime::getMonotonic ();
|
||||
epicsTime current = start;
|
||||
while ( current - start < interval ) {
|
||||
current = epicsTime::getCurrent ();
|
||||
current = epicsTime::getMonotonic ();
|
||||
}
|
||||
errorSum += threadSleepMeasureDelayError ( testInterval );
|
||||
if ( i % ( iterations / 10 ) == 0 ) {
|
||||
@@ -150,7 +150,7 @@ static void epicsThreadGetIdSelfPerfTest ()
|
||||
{
|
||||
static const unsigned N = 10000;
|
||||
static const double microSecPerSec = 1e6;
|
||||
epicsTime begin = epicsTime::getCurrent ();
|
||||
epicsTime begin = epicsTime::getMonotonic ();
|
||||
for ( unsigned i = 0u; i < N; i++ ) {
|
||||
epicsThreadGetIdSelf ();
|
||||
epicsThreadGetIdSelf ();
|
||||
@@ -164,7 +164,7 @@ static void epicsThreadGetIdSelfPerfTest ()
|
||||
epicsThreadGetIdSelf ();
|
||||
epicsThreadGetIdSelf ();
|
||||
};
|
||||
epicsTime end = epicsTime::getCurrent ();
|
||||
epicsTime end = epicsTime::getMonotonic ();
|
||||
printf ( "It takes %f micro sec to call epicsThreadGetIdSelf ()\n",
|
||||
microSecPerSec * ( end - begin ) / (10 * N) );
|
||||
}
|
||||
@@ -204,12 +204,12 @@ static void timeEpicsThreadPrivateGet ()
|
||||
{
|
||||
priv.set ( 0 );
|
||||
|
||||
epicsTime begin = epicsTime::getCurrent ();
|
||||
epicsTime begin = epicsTime::getMonotonic ();
|
||||
static const unsigned N = 1000u;
|
||||
for ( unsigned i = 0u; i < N; i++ ) {
|
||||
callItTenTimesSquared ();
|
||||
}
|
||||
double delay = epicsTime::getCurrent() - begin;
|
||||
double delay = epicsTime::getMonotonic() - begin;
|
||||
delay /= N * 100u; // convert to sec per call
|
||||
delay *= 1e6; // convert to micro sec
|
||||
printf("epicsThreadPrivateGet() takes %f microseconds\n", delay);
|
||||
|
||||
@@ -156,7 +156,7 @@ void testAccuracy ()
|
||||
|
||||
expireCount = nTimers;
|
||||
for ( i = 0u; i < nTimers; i++ ) {
|
||||
epicsTime cur = epicsTime::getCurrent ();
|
||||
epicsTime cur = epicsTime::getMonotonic ();
|
||||
pTimers[i]->setBegin ( cur );
|
||||
pTimers[i]->start ( cur + pTimers[i]->delay () );
|
||||
}
|
||||
@@ -253,7 +253,7 @@ void testCancel ()
|
||||
testDiag ( "cancelCount = %u", cancelVerify::cancelCount );
|
||||
|
||||
testDiag ( "starting %d timers", nTimers );
|
||||
epicsTime exp = epicsTime::getCurrent () + 4.0;
|
||||
epicsTime exp = epicsTime::getMonotonic () + 4.0;
|
||||
for ( i = 0u; i < nTimers; i++ ) {
|
||||
pTimers[i]->start ( exp );
|
||||
}
|
||||
@@ -339,7 +339,7 @@ void testExpireDestroy ()
|
||||
testOk1 ( expireDestroyVerify::destroyCount == 0 );
|
||||
|
||||
testDiag ( "starting %d timers", nTimers );
|
||||
epicsTime cur = epicsTime::getCurrent ();
|
||||
epicsTime cur = epicsTime::getMonotonic ();
|
||||
for ( i = 0u; i < nTimers; i++ ) {
|
||||
pTimers[i]->start ( cur );
|
||||
}
|
||||
@@ -432,7 +432,7 @@ void testPeriodic ()
|
||||
testOk1 ( timerCount == nTimers );
|
||||
|
||||
testDiag ( "starting %d timers", nTimers );
|
||||
epicsTime cur = epicsTime::getCurrent ();
|
||||
epicsTime cur = epicsTime::getMonotonic ();
|
||||
for ( i = 0u; i < nTimers; i++ ) {
|
||||
pTimers[i]->start ( cur );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user