diff options
Diffstat (limited to 'sim')
-rw-r--r-- | sim/main.cc | 20 | ||||
-rw-r--r-- | sim/sim_time.cc | 14 | ||||
-rw-r--r-- | sim/sim_time.hh | 4 |
3 files changed, 35 insertions, 3 deletions
diff --git a/sim/main.cc b/sim/main.cc index addedbc85..4fb075a2a 100644 --- a/sim/main.cc +++ b/sim/main.cc @@ -59,6 +59,7 @@ using namespace std; // See async.h. volatile bool async_event = false; volatile bool async_dump = false; +volatile bool async_dumpreset = false; volatile bool async_exit = false; volatile bool async_io = false; volatile bool async_alarm = false; @@ -71,6 +72,13 @@ dumpStatsHandler(int sigtype) async_dump = true; } +void +dumprstStatsHandler(int sigtype) +{ + async_event = true; + async_dumpreset = true; +} + /// Exit signal handler. void exitNowHandler(int sigtype) @@ -219,8 +227,9 @@ main(int argc, char **argv) signal(SIGFPE, SIG_IGN); // may occur on misspeculated paths signal(SIGPIPE, SIG_IGN); signal(SIGTRAP, SIG_IGN); - signal(SIGUSR1, dumpStatsHandler); // dump intermediate stats - signal(SIGINT, exitNowHandler); // dump final stats and exit + signal(SIGUSR1, dumpStatsHandler); // dump intermediate stats + signal(SIGUSR2, dumprstStatsHandler); // dump and reset stats + signal(SIGINT, exitNowHandler); // dump final stats and exit sayHello(cerr); @@ -405,6 +414,13 @@ main(int argc, char **argv) SetupEvent(Dump, curTick); } + if (async_dumpreset) { + async_dumpreset = false; + + using namespace Statistics; + SetupEvent(Dump | Reset, curTick); + } + if (async_exit) { async_exit = false; new SimExitEvent("User requested STOP"); diff --git a/sim/sim_time.cc b/sim/sim_time.cc index 70483d9a2..09c5a66de 100644 --- a/sim/sim_time.cc +++ b/sim/sim_time.cc @@ -65,6 +65,12 @@ namespace Time return start->tv; } + void + Start::reset() + { + ::gettimeofday(&start->tv, NULL); + } + double Start::operator()() const { @@ -115,10 +121,16 @@ namespace Time if (!elapsed) elapsed = new _timeval; - timersub(&now.get(), &start.get(), &elapsed->tv); + timersub(&_now.get(), &_start.get(), &elapsed->tv); return elapsed->tv; } + void + Elapsed::reset() + { + _start.reset(); + } + double Elapsed::operator()() const { diff --git a/sim/sim_time.hh b/sim/sim_time.hh index af69c3321..02ca5534f 100644 --- a/sim/sim_time.hh +++ b/sim/sim_time.hh @@ -45,6 +45,7 @@ namespace Time { ~Start(); const timeval &get() const; + void reset(); double operator()() const; }; @@ -65,12 +66,15 @@ namespace Time { { private: mutable _timeval *elapsed; + Start _start; + Now _now; public: Elapsed(); ~Elapsed(); const timeval &get() const; + void reset(); double operator()() const; }; |