Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

lfc::Chronometer Class Reference

represents an chronometer for measuring the processor time taken by some process. More...

Inheritance diagram for lfc::Chronometer::

lfc::Object lfc::_Serializable lfc::_Formatable List of all members.

Public Methods

 Chronometer () throw ()
virtual ~Chronometer () throw ()
virtual void start () throw ()
 starts the chronometer. More...

virtual void stop () throw ()
 stops the chronometer. More...

virtual const HiResTimeSpan duration () const throw ()
 
Returns:
the duration taken by the meassured process as a HiResTimeSpan.
More...


virtual void writeObject (BinaryOutput &stream) const
 platform independent serialization. More...

virtual void readObject (BinaryInput &stream)
 platform independent deserialization. More...

virtual void formatObject (TextOutput &stream, string format="") const
 formatting based on a certain format. More...


Protected Attributes

HiResTimeSpan m_start
HiResTimeSpan m_finish

Detailed Description

represents an chronometer for measuring the processor time taken by some process.

It should be used for profiling only, but be warned: it only counts processor time, so on posix systems, trying to measure empty loops and such will yield nothing.

Here's a small sample of how to use Chronometer:

    Chronometer c;
    File f("chronometerResults.txt", File::flWrite);
    lfcOut.connectOutputBase(f);

    for(int i = 6000; (i *= 10) <= 600000000; )
    {
        long temp = i;

        lfcOut << "Time taken to make " << i << " empty loops: ";

        c.start();
        while(--temp)
        {
        }
        c.stop();

        lfcOut << formattedOut(c, "-s 'secs', -ms 'msecs'") << ENDL;
    }
    
    lfcOut.disconnectOutputBase(f);

Todo:
make this thread safe

See also:
HiResTimeSpan


Constructor & Destructor Documentation

lfc::Chronometer::Chronometer   throw () [inline]
 

virtual lfc::Chronometer::~Chronometer   throw () [inline, virtual]
 


Member Function Documentation

virtual void lfc::Chronometer::start   throw () [inline, virtual]
 

starts the chronometer.

virtual void lfc::Chronometer::stop   throw () [inline, virtual]
 

stops the chronometer.

virtual const HiResTimeSpan lfc::Chronometer::duration   const throw () [inline, virtual]
 

Returns:
the duration taken by the meassured process as a HiResTimeSpan.

void lfc::Chronometer::writeObject BinaryOutput   stream const [virtual]
 

platform independent serialization.

Reimplemented from lfc::_Serializable.

void lfc::Chronometer::readObject BinaryInput   stream [virtual]
 

platform independent deserialization.

Reimplemented from lfc::_Serializable.

void lfc::Chronometer::formatObject TextOutput   stream,
string    format = ""
const [virtual]
 

formatting based on a certain format.

For Chronometer, formatting is done through HiResTimeSpan, so the format and rules are the same as for HiResTimeSpan.

Reimplemented from lfc::_Formatable.


Member Data Documentation

HiResTimeSpan lfc::Chronometer::m_start [protected]
 

HiResTimeSpan lfc::Chronometer::m_finish [protected]
 


The documentation for this class was generated from the following files:
Generated on Fri Jan 25 03:13:00 2002 for LFC2 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001