(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.
+2011-10-17 Cary Coutant <ccoutant@google.com>
+
+ * 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.
+
2011-10-17 Cary Coutant <ccoutant@google.com>
* readsyms.cc (Read_symbols::run): Don't queue an unblocker
#include "gc.h"
#include "icf.h"
#include "incremental.h"
+#include "timer.h"
namespace gold
{
Workqueue* workqueue,
Mapfile* mapfile)
{
+ Timer* timer = parameters->timer();
+ if (timer != NULL)
+ timer->stamp(0);
+
// Add any symbols named with -u options to the symbol table.
symtab->add_undefined_symbols_from_command_line(layout);
Workqueue* workqueue,
Output_file* of)
{
+ Timer* timer = parameters->timer();
+ if (timer != NULL)
+ timer->stamp(1);
+
int thread_count = options.thread_count_final();
if (thread_count == 0)
thread_count = std::max(2, input_objects->number_of_input_objects());
Timer timer;
if (command_line.options().stats())
- timer.start();
+ {
+ timer.start();
+ set_parameters_timer(&timer);
+ }
// Store some options in the globally accessible parameters.
set_parameters_options(&command_line.options());
if (command_line.options().stats())
{
- Timer::TimeStats elapsed = timer.get_elapsed_time();
+ timer.stamp(2);
+ Timer::TimeStats elapsed = timer.get_pass_time(0);
+ fprintf(stderr,
+ _("%s: initial tasks run time: " \
+ "(user: %ld.%06ld sys: %ld.%06ld wall: %ld.%06ld)\n"),
+ program_name,
+ elapsed.user / 1000, (elapsed.user % 1000) * 1000,
+ elapsed.sys / 1000, (elapsed.sys % 1000) * 1000,
+ elapsed.wall / 1000, (elapsed.wall % 1000) * 1000);
+ elapsed = timer.get_pass_time(1);
+ fprintf(stderr,
+ _("%s: middle tasks run time: " \
+ "(user: %ld.%06ld sys: %ld.%06ld wall: %ld.%06ld)\n"),
+ program_name,
+ elapsed.user / 1000, (elapsed.user % 1000) * 1000,
+ elapsed.sys / 1000, (elapsed.sys % 1000) * 1000,
+ elapsed.wall / 1000, (elapsed.wall % 1000) * 1000);
+ elapsed = timer.get_pass_time(2);
+ fprintf(stderr,
+ _("%s: final tasks run time: " \
+ "(user: %ld.%06ld sys: %ld.%06ld wall: %ld.%06ld)\n"),
+ program_name,
+ elapsed.user / 1000, (elapsed.user % 1000) * 1000,
+ elapsed.sys / 1000, (elapsed.sys % 1000) * 1000,
+ elapsed.wall / 1000, (elapsed.wall % 1000) * 1000);
+ elapsed = timer.get_elapsed_time();
fprintf(stderr,
_("%s: total run time: " \
"(user: %ld.%06ld sys: %ld.%06ld wall: %ld.%06ld)\n"),
// Class Parameters.
Parameters::Parameters()
- : errors_(NULL), options_(NULL), target_(NULL),
+ : errors_(NULL), timer_(NULL), options_(NULL), target_(NULL),
doing_static_link_valid_(false), doing_static_link_(false),
debug_(0), incremental_mode_(General_options::INCREMENTAL_OFF),
set_parameters_target_once_(&set_parameters_target_once)
this->errors_ = errors;
}
+void
+Parameters::set_timer(Timer* timer)
+{
+ gold_assert(this->timer_ == NULL);
+ this->timer_ = timer;
+}
+
void
Parameters::set_options(const General_options* options)
{
set_parameters_errors(Errors* errors)
{ static_parameters.set_errors(errors); }
+void
+set_parameters_timer(Timer* timer)
+{ static_parameters.set_timer(timer); }
+
void
set_parameters_options(const General_options* options)
{ static_parameters.set_options(options); }
class General_options;
class Errors;
+class Timer;
class Target;
template<int size, bool big_endian>
class Sized_target;
void
set_errors(Errors* errors);
+ void
+ set_timer(Timer* timer);
+
void
set_options(const General_options* options);
errors() const
{ return this->errors_; }
+ // Return the timer object.
+ Timer*
+ timer() const
+ { return this->timer_; }
+
// Whether the options are valid. This should not normally be
// called, but it is needed by gold_exit.
bool
friend class Set_parameters_target_once;
Errors* errors_;
+ Timer* timer_;
const General_options* options_;
Target* target_;
bool doing_static_link_valid_;
extern void
set_parameters_errors(Errors* errors);
+extern void
+set_parameters_timer(Timer* timer);
+
extern void
set_parameters_options(const General_options* options);
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
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;
+}
+
}
TimeStats
get_elapsed_time();
+ // Return the stats for pass N (0 <= N <= 2).
+ TimeStats
+ get_pass_time(int n);
+
// Start counting the time.
void
start();
+ // Record the time used by pass N (0 <= N <= 2).
+ void
+ stamp(int n);
+
private:
// This class cannot be copied.
Timer(const Timer&);
// The time of the last call to start.
TimeStats start_time_;
+
+ // Times for each pass.
+ TimeStats pass_times_[3];
};
}