Created
September 1, 2011 01:55
-
-
Save springmeyer/1185228 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: include/mapnik/timer.hpp | |
=================================================================== | |
--- include/mapnik/timer.hpp (revision 3246) | |
+++ include/mapnik/timer.hpp (working copy) | |
@@ -40,14 +40,14 @@ | |
void restart() | |
{ | |
- _wall_clock_end = NULL; | |
- _cpu_end = NULL; | |
+ //_wall_clock_end = NULL; | |
+ //_cpu_end = NULL; | |
gettimeofday(&_wall_clock_start, NULL); | |
_cpu_start = clock(); | |
} | |
- virtual void stop() | |
+ virtual void stop() const | |
{ | |
_cpu_end = clock(); | |
gettimeofday(&_wall_clock_end, NULL); | |
@@ -65,8 +65,8 @@ | |
double wall_clock_elapsed() const | |
{ | |
// return elapsed wall clock time in ms | |
- if (!_wall_clock_end) | |
- stop(); | |
+ //if (!_wall_clock_end) | |
+ // stop(); | |
long seconds = _wall_clock_end.tv_sec - _wall_clock_start.tv_sec; | |
long useconds = _wall_clock_end.tv_usec - _wall_clock_start.tv_usec; | |
@@ -74,8 +74,8 @@ | |
return ((seconds) * 1000 + useconds / 1000.0) + 0.5; | |
} | |
private: | |
- timeval _wall_clock_start, _wall_clock_end; | |
- clock_t _cpu_start, _cpu_end; | |
+ mutable timeval _wall_clock_start, _wall_clock_end; | |
+ mutable clock_t _cpu_start, _cpu_end; | |
}; | |
// A progress_timer behaves like a timer except that the destructor displays | |
@@ -94,7 +94,8 @@ | |
stop(); | |
} | |
- void stop() { | |
+ void stop() const | |
+ { | |
timer::stop(); | |
stopped_ = true; | |
@@ -103,7 +104,7 @@ | |
std::ostringstream s; | |
s.precision(2); | |
s << std::fixed; | |
- s << wall_clock_elapsed() << "ms (cpu " << cpu_elapsed() << "ms)" | |
+ s << wall_clock_elapsed() << "ms (cpu " << cpu_elapsed() << "ms)"; | |
s << std::setw(30 - (int)s.tellp()) << std::right << "| " << base_message_ << "\n"; | |
os_ << s.str(); | |
} | |
@@ -117,7 +118,7 @@ | |
private: | |
std::ostream & os_; | |
std::string base_message_; | |
- bool stopped_; | |
+ mutable bool stopped_; | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment