Style and little fix in ITAStopWatch string converter. Also added outstream...

Style and little fix in ITAStopWatch string converter. Also added outstream operator for stopwatch statistics
parent 54a487bc
......@@ -24,24 +24,24 @@
#include <stddef.h>
//! Converts signed integer 16-Bit -> single precision floating point (32-Bit)
void ITA_BASE_API stc_sint16_to_float(float* dest, const short* src, size_t count, int input_stride = 1, int output_stride = 1);
void ITA_BASE_API stc_sint16_to_float( float* dest, const short* src, size_t count, int input_stride = 1, int output_stride = 1 );
//! Converts signed integer 24-Bit -> single precision floating point (32-Bit)
void ITA_BASE_API stc_sint24_to_float(float* dest, const void* src, size_t count, int input_stride = 1, int output_stride = 1);
void ITA_BASE_API stc_sint24_to_float( float* dest, const void* src, size_t count, int input_stride = 1, int output_stride = 1 );
//! Converts signed integer 32-Bit -> single precision floating point (32-Bit)
void ITA_BASE_API stc_sint32_to_float(float* dest, const int* src, size_t count, int input_stride = 1, int output_stride = 1);
void ITA_BASE_API stc_sint32_to_float( float* dest, const int* src, size_t count, int input_stride = 1, int output_stride = 1 );
//! Converts double precision floating point (64-Bit) -> single precision floating point (32-Bit)
void ITA_BASE_API stc_double_to_float(float* dest, const double* src, size_t count, int input_stride = 1, int output_stride = 1);
void ITA_BASE_API stc_double_to_float( float* dest, const double* src, size_t count, int input_stride = 1, int output_stride = 1 );
//! Converts single precision floating point (32-Bit) -> signed integer 16-Bit
void ITA_BASE_API stc_float_to_sint16(short* dest, const float* src, size_t count, int input_stride = 1, int output_stride = 1);
void ITA_BASE_API stc_float_to_sint16( short* dest, const float* src, size_t count, int input_stride = 1, int output_stride = 1 );
//! Converts single precision floating point (32-Bit) -> signed integer 32-Bit
void ITA_BASE_API stc_float_to_sint32(int* dest, const float* src, size_t count, int input_stride = 1, int output_stride = 1);
void ITA_BASE_API stc_float_to_sint32( int* dest, const float* src, size_t count, int input_stride = 1, int output_stride = 1 );
//! Converts single precision floating point (32-Bit) -> double precision floating point (64-Bit)
void ITA_BASE_API stc_float_to_double(double* dest, const float* src, size_t count, int input_stride = 1, int output_stride = 1);
void ITA_BASE_API stc_float_to_double( double* dest, const float* src, size_t count, int input_stride = 1, int output_stride = 1 );
#endif // INCLUDE_WATCHER_ITA_SAMPLE_TYPE_CONVERSION
......@@ -48,7 +48,7 @@ public:
ITAStopWatch();
//! Konstruktor
ITAStopWatch(ITAClock* pClock);
ITAStopWatch( ITAClock* pClock );
//! Zurücksetzen
/**
......@@ -132,7 +132,7 @@ public:
/**
* Die Standardabweichung aller gemessenen Zeiten berechnet
* sich als Quadratwurzel der Varianz.
*
*
* \return Standardabweichung aller gemessenen Zeiten [in Sekunden]
* \note Wurden noch keine Messungen durchgeführt, ist der Rückgabewert 0
*/
......@@ -146,14 +146,14 @@ public:
* (Hinweis: Die Stopwatch berücksichtigt eine Grundlatenz (Verzögerung
* zwischen Aufrufen von start() und stop()), welche von allen Messwerten
* abgezogen wird die stop() zurückgibt).
*
*
* In der Praxis ergeben sich größere Werte, falls im Debug-Modus
* kompiliert wurde. In allen Fällen sollte der Wert aber <= 1ns sein.
* (Testsystem: Pentium M 1.4 GHz)
*
* \return Durchschnittsdauer in Sekunden
*/
static double selftest();
static double selftest();
//! Einen formattierten String ausgeben, der den status der Stopwatch formuliert
std::string ToString() const;
......@@ -170,4 +170,11 @@ private:
ITACriticalSection m_csReadWrite;
};
//! Outstream operator
inline std::ostream& operator<<( std::ostream& os, ITAStopWatch& sw )
{
os << sw.ToString();
return os;
};
#endif // INCLUDE_WATCHER_ITA_STOP_WATCH
......@@ -68,7 +68,7 @@ ITA_BASE_API std::string toUppercase( const std::string& s );
ITA_BASE_API std::string BoolToString( bool bValue );
//! int nach std::string konvertieren
ITA_BASE_API std::string IntToString( int iValue );
ITA_BASE_API std::string IntToString( const int iValue );
//! unsigned int nach std::string konvertieren
ITA_BASE_API std::string UIntToString( unsigned int uiValue );
......
......@@ -14,7 +14,8 @@ 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();
......@@ -121,7 +122,7 @@ unsigned int ITAStopWatch::cycles() const
double ITAStopWatch::minimum() const
{
return ( m_uiCycles == 0 ? 0 : m_dMin );
return ( m_uiCycles == 0 ? 0.0f : m_dMin );
}
double ITAStopWatch::maximum() const
......@@ -184,14 +185,20 @@ double ITAStopWatch::selftest()
return sw.mean();
}
std::string TimeToString( double dTimeSeconds )
std::string TimeToString( const double dTimeSeconds )
{
std::stringstream ss;
if( dTimeSeconds < 1e-6 )
ss << dTimeSeconds / 1e-9 << "us";
else if( dTimeSeconds < 1e-3 )
ss << dTimeSeconds / 1e-6 << "ns";
else if( dTimeSeconds < 1e-0 )
if( std::abs( dTimeSeconds ) == 0.0f )
ss << "zero";
else if( std::abs( dTimeSeconds ) < 1e-12 )
ss << dTimeSeconds / 1e-15 << "fs";
else if( std::abs( dTimeSeconds ) < 1e-9 )
ss << dTimeSeconds / 1e-12 << "ps";
else if( std::abs( dTimeSeconds ) < 1e-6 )
ss << dTimeSeconds / 1e-9 << "ns";
else if( std::abs( dTimeSeconds ) < 1e-3 )
ss << dTimeSeconds / 1e-6 << "us";
else if( std::abs( dTimeSeconds ) < 1e-0 )
ss << dTimeSeconds / 1e-3 << "ms";
else
ss << dTimeSeconds << "s";
......
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