diff options
Diffstat (limited to 'gold/main.cc')
-rw-r--r-- | gold/main.cc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/gold/main.cc b/gold/main.cc index ccd958d..49b50b2 100644 --- a/gold/main.cc +++ b/gold/main.cc @@ -22,6 +22,11 @@ #include "gold.h" +#ifdef HAVE_MALLINFO +#include <malloc.h> +#endif +#include "libiberty.h" + #include "options.h" #include "parameters.h" #include "dirsearch.h" @@ -49,6 +54,11 @@ main(int argc, char** argv) // Handle the command line options. Command_line command_line; command_line.process(argc - 1, argv + 1); + + long start_time = 0; + if (command_line.options().print_stats()) + start_time = get_run_time(); + initialize_parameters(&command_line.options()); // The work queue. @@ -75,5 +85,20 @@ main(int argc, char** argv) // Run the main task processing loop. workqueue.process(); + if (command_line.options().print_stats()) + { + long run_time = get_run_time() - start_time; + fprintf(stderr, _("%s: total run time: %ld.%06ld seconds\n"), + program_name, run_time / 1000000, run_time % 1000000); +#ifdef HAVE_MALLINFO + struct mallinfo m = mallinfo(); + fprintf(stderr, _("%s: total space allocated by malloc: %d bytes\n"), + program_name, m.arena); +#endif + File_read::print_stats(); + fprintf(stderr, _("%s: output file size: %lld bytes\n"), + program_name, static_cast<long long>(layout.output_file_size())); + } + gold_exit(true); } |