aboutsummaryrefslogtreecommitdiff
path: root/gold/timer.cc
diff options
context:
space:
mode:
authorCary Coutant <ccoutant@google.com>2011-10-18 00:06:10 +0000
committerCary Coutant <ccoutant@google.com>2011-10-18 00:06:10 +0000
commitb490c0bbaf81fb741c6751eff30082883343e2ff (patch)
treefbfdd4a8a314245629467b77cc7fa4203fac6a23 /gold/timer.cc
parent41835e6a39b581ab4f7fba25e02aba01e50a8521 (diff)
downloadgdb-b490c0bbaf81fb741c6751eff30082883343e2ff.zip
gdb-b490c0bbaf81fb741c6751eff30082883343e2ff.tar.gz
gdb-b490c0bbaf81fb741c6751eff30082883343e2ff.tar.bz2
* gold.cc: Include timer.h.
(queue_middle_tasks): Stamp time. (queue_final_tasks): Likewise. * main.cc (main): Store timer in parameters. Print timers for each pass. * parameters.cc (Parameters::Parameters): Initialize timer_. (Parameters::set_timer): New function. (set_parameters_timer): New function. * parameters.h (Parameters::set_timer): New function. (Parameters::timer): New function. (Parameters::timer_): New data member. (set_parameters_timer): New function. * timer.cc (Timer::stamp): New function. (Timer::get_pass_time): New function. * timer.h (Timer::stamp): New function. (Timer::get_pass_time): New function. (Timer::pass_times_): New data member.
Diffstat (limited to 'gold/timer.cc')
-rw-r--r--gold/timer.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/gold/timer.cc b/gold/timer.cc
index d9b8874..1423663 100644
--- a/gold/timer.cc
+++ b/gold/timer.cc
@@ -49,6 +49,15 @@ Timer::start()
this->get_time(&this->start_time_);
}
+// Record the time used by pass N (0 <= N <= 2).
+void
+Timer::stamp(int n)
+{
+ gold_assert(n >= 0 && n <= 2);
+ TimeStats& thispass = this->pass_times_[n];
+ this->get_time(&thispass);
+}
+
#if HAVE_SYSCONF && defined _SC_CLK_TCK
# define TICKS_PER_SECOND sysconf (_SC_CLK_TCK) /* POSIX 1003.1-1996 */
#else
@@ -106,4 +115,17 @@ Timer::get_elapsed_time()
return delta;
}
+// Return the stats for pass N (0 <= N <= 2).
+Timer::TimeStats
+Timer::get_pass_time(int n)
+{
+ gold_assert(n >= 0 && n <= 2);
+ TimeStats thispass = this->pass_times_[n];
+ TimeStats& lastpass = n > 0 ? this->pass_times_[n-1] : this->start_time_;
+ thispass.wall -= lastpass.wall;
+ thispass.user -= lastpass.user;
+ thispass.sys -= lastpass.sys;
+ return thispass;
+}
+
}