Commit fc1ffa56 authored by tfarina@chromium.org's avatar tfarina@chromium.org

Make use of ElapsedTimer API for the 'gen' command.

BUG=None
TEST=run ./out/Default/gn, it should reporte the elapsed time without no
regressions.
R=brettw@chromium.org

Review URL: https://codereview.chromium.org/124803002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243888 0039d316-1c4b-4281-b951-d872f2087c98
parent d656595b
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/time/time.h" #include "base/timer/elapsed_timer.h"
#include "tools/gn/build_settings.h" #include "tools/gn/build_settings.h"
#include "tools/gn/commands.h" #include "tools/gn/commands.h"
#include "tools/gn/ninja_target_writer.h" #include "tools/gn/ninja_target_writer.h"
...@@ -57,7 +57,7 @@ const char kGen_Help[] = ...@@ -57,7 +57,7 @@ const char kGen_Help[] =
// Note: partially duplicated in command_gyp.cc. // Note: partially duplicated in command_gyp.cc.
int RunGen(const std::vector<std::string>& args) { int RunGen(const std::vector<std::string>& args) {
base::TimeTicks begin_time = base::TimeTicks::Now(); base::ElapsedTimer timer;
// Deliberately leaked to avoid expensive process teardown. // Deliberately leaked to avoid expensive process teardown.
Setup* setup = new Setup; Setup* setup = new Setup;
...@@ -80,7 +80,7 @@ int RunGen(const std::vector<std::string>& args) { ...@@ -80,7 +80,7 @@ int RunGen(const std::vector<std::string>& args) {
setup->builder())) setup->builder()))
return 1; return 1;
base::TimeTicks end_time = base::TimeTicks::Now(); base::TimeDelta elapsed_time = timer.Elapsed();
if (!CommandLine::ForCurrentProcess()->HasSwitch(kSwitchQuiet)) { if (!CommandLine::ForCurrentProcess()->HasSwitch(kSwitchQuiet)) {
OutputString("Done. ", DECORATION_GREEN); OutputString("Done. ", DECORATION_GREEN);
...@@ -91,7 +91,7 @@ int RunGen(const std::vector<std::string>& args) { ...@@ -91,7 +91,7 @@ int RunGen(const std::vector<std::string>& args) {
base::IntToString( base::IntToString(
setup->scheduler().input_file_manager()->GetInputFileCount()) + setup->scheduler().input_file_manager()->GetInputFileCount()) +
" files in " + " files in " +
base::IntToString((end_time - begin_time).InMilliseconds()) + "ms\n"; base::IntToString(elapsed_time.InMilliseconds()) + "ms\n";
OutputString(stats); OutputString(stats);
} }
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/environment.h" #include "base/environment.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/time/time.h" #include "base/timer/elapsed_timer.h"
#include "tools/gn/build_settings.h" #include "tools/gn/build_settings.h"
#include "tools/gn/commands.h" #include "tools/gn/commands.h"
#include "tools/gn/err.h" #include "tools/gn/err.h"
...@@ -326,9 +326,7 @@ const char kGyp_Help[] = ...@@ -326,9 +326,7 @@ const char kGyp_Help[] =
" }\n"; " }\n";
int RunGyp(const std::vector<std::string>& args) { int RunGyp(const std::vector<std::string>& args) {
const CommandLine* cmdline = CommandLine::ForCurrentProcess(); base::ElapsedTimer timer;
base::TimeTicks begin_time = base::TimeTicks::Now();
// Deliberately leaked to avoid expensive process teardown. // Deliberately leaked to avoid expensive process teardown.
Setup* setup_debug = new Setup; Setup* setup_debug = new Setup;
...@@ -407,9 +405,9 @@ int RunGyp(const std::vector<std::string>& args) { ...@@ -407,9 +405,9 @@ int RunGyp(const std::vector<std::string>& args) {
return 1; return 1;
} }
// Timing info. base::TimeDelta elapsed_time = timer.Elapsed();
base::TimeTicks end_time = base::TimeTicks::Now();
if (!cmdline->HasSwitch(kSwitchQuiet)) { if (!CommandLine::ForCurrentProcess()->HasSwitch(kSwitchQuiet)) {
OutputString("Done. ", DECORATION_GREEN); OutputString("Done. ", DECORATION_GREEN);
std::string stats = "Wrote " + std::string stats = "Wrote " +
...@@ -418,7 +416,7 @@ int RunGyp(const std::vector<std::string>& args) { ...@@ -418,7 +416,7 @@ int RunGyp(const std::vector<std::string>& args) {
base::IntToString( base::IntToString(
setup_debug->scheduler().input_file_manager()->GetInputFileCount()) setup_debug->scheduler().input_file_manager()->GetInputFileCount())
+ " GN files in " + + " GN files in " +
base::IntToString((end_time - begin_time).InMilliseconds()) + "ms\n"; base::IntToString(elapsed_time.InMilliseconds()) + "ms\n";
OutputString(stats); OutputString(stats);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment