version 1.14, 2005/02/05 22:59:24
|
version 1.15, 2005/03/07 16:06:12
|
|
|
// Author: Mike Brasher (mbrasher@bmc.com) | // Author: Mike Brasher (mbrasher@bmc.com) |
// | // |
// Modified By: | // Modified By: |
|
// Chip Vincent (cvincent@us.ibm.com) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
#include <iostream> |
|
#include "Stopwatch.h" | #include "Stopwatch.h" |
#include "TimeValue.h" |
|
|
#include <Pegasus/Common/TimeValue.h> |
|
#include <Pegasus/Common/System.h> |
|
|
|
#include <iostream> |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
#include <Pegasus/Common/System.h> |
Stopwatch::Stopwatch(void) : _start(0), _stop(0), _total(0) |
|
{ |
|
} |
|
|
|
void Stopwatch::start(void) |
|
{ |
|
_start = TimeValue::getCurrentTime().toMilliseconds(); |
|
} |
| |
Stopwatch::Stopwatch() |
void Stopwatch::stop(void) |
{ | { |
reset(); |
_stop = TimeValue::getCurrentTime().toMilliseconds(); |
|
|
|
// update total |
|
_total += double(_stop - _start); |
} | } |
| |
void Stopwatch::reset() |
void Stopwatch::reset(void) |
{ | { |
_start = TimeValue::getCurrentTime(); |
_start = 0; |
|
_stop = 0; |
|
_total = 0; |
} | } |
| |
double Stopwatch::getElapsed() const |
double Stopwatch::getElapsed(void) const |
{ | { |
Uint32 stop = TimeValue::getCurrentTime().toMilliseconds(); |
return(_total / 1000.0); |
Uint32 start = _start.toMilliseconds(); |
|
return double(stop - start) / 1000.0; |
|
} | } |
| |
void Stopwatch::printElapsed() |
void Stopwatch::printElapsed(void) |
{ | { |
PEGASUS_STD(cout) << getElapsed() << " seconds" << PEGASUS_STD(endl); | PEGASUS_STD(cout) << getElapsed() << " seconds" << PEGASUS_STD(endl); |
} | } |