Style

parent 135405c6
......@@ -122,7 +122,8 @@ template< class T > void ITABufferedDataLogger< T >::setOutputFile( const std::s
m_sOutputFile = sFilename;
};
template< class T > void ITABufferedDataLogger< T >::clear() {
template< class T > void ITABufferedDataLogger< T >::clear()
{
m_vLogItems.clear();
};
......
......@@ -10,17 +10,17 @@
bool ITAStopWatch::m_bInstanceCreated = false;
double ITAStopWatch::m_dStartStopLatency = 0;
ITAStopWatch::ITAStopWatch()
: m_pClock( ITAClock::getDefaultClock() )
ITAStopWatch::ITAStopWatch()
: m_pClock( ITAClock::getDefaultClock() )
{
// Falls dies die erste Stopwatch ist die erzeugt wird: Latenz messen
if (!m_bInstanceCreated) {
if( !m_bInstanceCreated ) {
ITACriticalSection cs;
cs.enter();
start();
stop();
reset();
for (unsigned int i=0; i<100; i++) {
for( unsigned int i = 0; i < 100; i++ ) {
start();
stop();
}
......@@ -29,7 +29,7 @@ ITAStopWatch::ITAStopWatch()
/* DEBUG:
printf("%s: Measured start/stop latency: %0.3f ns\n",
__FUNCTION__, _dStartStopLatency * 1000000000);
__FUNCTION__, _dStartStopLatency * 1000000000);
*/
m_bInstanceCreated = true;
......@@ -42,32 +42,32 @@ ITAStopWatch::ITAStopWatch( ITAClock* pClock )
: m_pClock( pClock )
{
if (!pClock)
ITA_EXCEPT1(INVALID_PARAMETER, "Clock must not be NULL");
if( !pClock )
ITA_EXCEPT1( INVALID_PARAMETER, "Clock must not be NULL" );
// Falls dies die erste Stopwatch ist die erzeugt wird: Latenz messen
if (!m_bInstanceCreated)
if( !m_bInstanceCreated )
{
ITACriticalSection cs;
cs.enter();
start();
stop();
reset();
for (unsigned int i=0; i<100; i++)
for( unsigned int i = 0; i < 100; i++ )
{
start();
stop();
}
cs.leave();
m_dStartStopLatency = minimum();
m_bInstanceCreated = true;
}
reset();
}
void ITAStopWatch::reset()
void ITAStopWatch::reset()
{
m_csReadWrite.enter();
m_uiCycles = 0;
......@@ -111,7 +111,7 @@ double ITAStopWatch::stop()
}
unsigned int ITAStopWatch::cycles() const
{
{
m_csReadWrite.enter();
unsigned int uiResult = m_uiCycles;
m_csReadWrite.leave();
......@@ -119,8 +119,8 @@ unsigned int ITAStopWatch::cycles() const
}
double ITAStopWatch::minimum() const
{
return (m_uiCycles == 0 ? 0 : m_dMin);
{
return ( m_uiCycles == 0 ? 0 : m_dMin );
}
double ITAStopWatch::maximum() const
......@@ -130,52 +130,52 @@ double ITAStopWatch::maximum() const
double ITAStopWatch::mean() const
{
if (m_csReadWrite.tryenter() == true )
if( m_csReadWrite.tryenter() == true )
{
if (m_uiCycles == 0)
if( m_uiCycles == 0 )
{
m_csReadWrite.leave();
return -1;
return 0;
}
double dResult = m_dSum / m_uiCycles;
m_csReadWrite.leave();
return dResult;
}
return -1;
return 0;
}
double ITAStopWatch::variance() const
{
if (m_csReadWrite.tryenter() == true)
if( m_csReadWrite.tryenter() == true )
{
if (m_uiCycles == 0) {
if( m_uiCycles == 0 ) {
m_csReadWrite.leave();
return -1;
return 0;
}
// Formel: sigma = E(X^2) - E(X)^2
double x = (m_dSum / m_uiCycles);
double dResult = (m_dSquareSum / m_uiCycles) - (x*x);
double x = ( m_dSum / m_uiCycles );
double dResult = ( m_dSquareSum / m_uiCycles ) - ( x*x );
m_csReadWrite.leave();
return dResult;
}
return -1;
return 0;
}
double ITAStopWatch::std_deviation() const
{
return sqrt(variance());
double ITAStopWatch::std_deviation() const
{
return sqrt( variance() );
}
double ITAStopWatch::selftest()
double ITAStopWatch::selftest()
{
ITAStopWatch sw;
sw.start();
sw.stop();
sw.reset();
for (int i=0; i<1000; i++)
for( int i = 0; i < 1000; i++ )
{
sw.start();
sw.stop();
......@@ -183,14 +183,14 @@ double ITAStopWatch::selftest()
return sw.mean();
}
std::string TimeToString( double dTimeSeconds)
std::string TimeToString( double dTimeSeconds )
{
std::stringstream ss;
if( dTimeSeconds < 1e-6 )
ss << dTimeSeconds / 1e-9 << "us";
else if (dTimeSeconds < 1e-3)
else if( dTimeSeconds < 1e-3 )
ss << dTimeSeconds / 1e-6 << "ns";
else if (dTimeSeconds < 1e-0)
else if( dTimeSeconds < 1e-0 )
ss << dTimeSeconds / 1e-3 << "ms";
else
ss << dTimeSeconds << "s";
......@@ -201,10 +201,10 @@ std::string TimeToString( double dTimeSeconds)
std::string ITAStopWatch::ToString() const
{
std::ostringstream ss;
ss << "avg=" << TimeToString(mean()) << ", ";
ss << "stddev=" << TimeToString(std_deviation()) << ", ";
ss << "min=" << TimeToString(minimum()) << ", ";
ss << "max=" << TimeToString(maximum()) << ", ";
ss << "avg=" << TimeToString( mean() ) << ", ";
ss << "stddev=" << TimeToString( std_deviation() ) << ", ";
ss << "min=" << TimeToString( minimum() ) << ", ";
ss << "max=" << TimeToString( maximum() ) << ", ";
ss << "cycles=" << cycles();
return ss.str();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment