* 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.
This commit is contained in:
parent
41835e6a39
commit
b490c0bbaf
@ -1,3 +1,23 @@
|
||||
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
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "gc.h"
|
||||
#include "icf.h"
|
||||
#include "incremental.h"
|
||||
#include "timer.h"
|
||||
|
||||
namespace gold
|
||||
{
|
||||
@ -487,6 +488,10 @@ queue_middle_tasks(const General_options& options,
|
||||
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);
|
||||
|
||||
@ -786,6 +791,10 @@ queue_final_tasks(const General_options& options,
|
||||
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());
|
||||
|
32
gold/main.cc
32
gold/main.cc
@ -165,7 +165,10 @@ main(int argc, char** argv)
|
||||
|
||||
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());
|
||||
@ -252,7 +255,32 @@ main(int argc, char** argv)
|
||||
|
||||
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"),
|
||||
|
@ -64,7 +64,7 @@ Set_parameters_target_once set_parameters_target_once(&static_parameters);
|
||||
// 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)
|
||||
@ -78,6 +78,13 @@ Parameters::set_errors(Errors* errors)
|
||||
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)
|
||||
{
|
||||
@ -269,6 +276,10 @@ void
|
||||
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); }
|
||||
|
@ -28,6 +28,7 @@ namespace gold
|
||||
|
||||
class General_options;
|
||||
class Errors;
|
||||
class Timer;
|
||||
class Target;
|
||||
template<int size, bool big_endian>
|
||||
class Sized_target;
|
||||
@ -56,6 +57,9 @@ class Parameters
|
||||
void
|
||||
set_errors(Errors* errors);
|
||||
|
||||
void
|
||||
set_timer(Timer* timer);
|
||||
|
||||
void
|
||||
set_options(const General_options* options);
|
||||
|
||||
@ -70,6 +74,11 @@ class Parameters
|
||||
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
|
||||
@ -177,6 +186,7 @@ class Parameters
|
||||
friend class Set_parameters_target_once;
|
||||
|
||||
Errors* errors_;
|
||||
Timer* timer_;
|
||||
const General_options* options_;
|
||||
Target* target_;
|
||||
bool doing_static_link_valid_;
|
||||
@ -195,6 +205,9 @@ extern const Parameters* parameters;
|
||||
extern void
|
||||
set_parameters_errors(Errors* errors);
|
||||
|
||||
extern void
|
||||
set_parameters_timer(Timer* timer);
|
||||
|
||||
extern void
|
||||
set_parameters_options(const General_options* options);
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
11
gold/timer.h
11
gold/timer.h
@ -48,10 +48,18 @@ class Timer
|
||||
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&);
|
||||
@ -63,6 +71,9 @@ class Timer
|
||||
|
||||
// The time of the last call to start.
|
||||
TimeStats start_time_;
|
||||
|
||||
// Times for each pass.
|
||||
TimeStats pass_times_[3];
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user