added epicsThreadIdGetSelf() performance test

This commit is contained in:
Jeff Hill
2002-12-11 22:56:53 +00:00
parent 5aa8fbb3c9
commit 3c136f74d8

View File

@@ -11,6 +11,7 @@
/* Author: Marty Kraimer Date: 26JAN2000 */
/* sleep accuracy tests by Jeff Hill */
/* epicsThreadGetIdSelf performance by Jeff Hill */
#include <stddef.h>
#include <stdlib.h>
@@ -82,6 +83,29 @@ static void threadSleepTest()
printf ( "Average error %f sec\n", errorSum / ( i + 1 ) );
}
static void epicsThreadGetIdSelfPerfTest ()
{
static const unsigned N = 10000;
static const double microSecPerSec = 1e6;
epicsTime begin = epicsTime::getCurrent ();
for ( unsigned i = 0u; i < N; i++ ) {
epicsThreadGetIdSelf ();
epicsThreadGetIdSelf ();
epicsThreadGetIdSelf ();
epicsThreadGetIdSelf ();
epicsThreadGetIdSelf ();
epicsThreadGetIdSelf ();
epicsThreadGetIdSelf ();
epicsThreadGetIdSelf ();
epicsThreadGetIdSelf ();
epicsThreadGetIdSelf ();
};
epicsTime end = epicsTime::getCurrent ();
printf ( "It takes %f micro sec to call epicsThreadGetIdSelf ()\n",
microSecPerSec * ( end - begin ) / (10 * N) );
}
extern "C" void threadTest(int ntasks,int verbose)
{
myThread **papmyThread;
@@ -90,6 +114,8 @@ extern "C" void threadTest(int ntasks,int verbose)
int startPriority,minPriority,maxPriority;
int errVerboseSave = errVerbose;
epicsThreadGetIdSelfPerfTest ();
threadSleepTest();
errVerbose = verbose;