aboutsummaryrefslogtreecommitdiff
path: root/gold/main.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2007-10-12 05:51:25 +0000
committerIan Lance Taylor <iant@google.com>2007-10-12 05:51:25 +0000
commite44fcf3bcf912ddf4ce94f9c3f71c253d473d692 (patch)
tree3f5de3fdbbc7b5ba332f8d2123f017c2e8437ce6 /gold/main.cc
parent6ca8706da5d2154ee86544024f708fda30efba26 (diff)
downloadgdb-e44fcf3bcf912ddf4ce94f9c3f71c253d473d692.zip
gdb-e44fcf3bcf912ddf4ce94f9c3f71c253d473d692.tar.gz
gdb-e44fcf3bcf912ddf4ce94f9c3f71c253d473d692.tar.bz2
Add --stats option to print runtime and memory usage statistics.
Diffstat (limited to 'gold/main.cc')
-rw-r--r--gold/main.cc25
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);
}