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:
@@ -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