Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: tools/gn/command_gyp.cc

Issue 124803002: Make use of ElapsedTimer API for the 'gen' command. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update command_gyp as well Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/gn/command_gen.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <iostream> 5 #include <iostream>
6 #include <map> 6 #include <map>
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/environment.h" 11 #include "base/environment.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/time/time.h" 13 #include "base/timer/elapsed_timer.h"
14 #include "tools/gn/build_settings.h" 14 #include "tools/gn/build_settings.h"
15 #include "tools/gn/commands.h" 15 #include "tools/gn/commands.h"
16 #include "tools/gn/err.h" 16 #include "tools/gn/err.h"
17 #include "tools/gn/filesystem_utils.h" 17 #include "tools/gn/filesystem_utils.h"
18 #include "tools/gn/gyp_helper.h" 18 #include "tools/gn/gyp_helper.h"
19 #include "tools/gn/gyp_target_writer.h" 19 #include "tools/gn/gyp_target_writer.h"
20 #include "tools/gn/location.h" 20 #include "tools/gn/location.h"
21 #include "tools/gn/parser.h" 21 #include "tools/gn/parser.h"
22 #include "tools/gn/setup.h" 22 #include "tools/gn/setup.h"
23 #include "tools/gn/source_file.h" 23 #include "tools/gn/source_file.h"
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 " direct_dependen_configs = [ \":gyp_target_config\" ]\n" 319 " direct_dependen_configs = [ \":gyp_target_config\" ]\n"
320 " }\n" 320 " }\n"
321 "\n" 321 "\n"
322 " executable(\"my_app\") {\n" 322 " executable(\"my_app\") {\n"
323 " deps = [ \":gyp_target\" ]\n" 323 " deps = [ \":gyp_target\" ]\n"
324 " gyp_file = \"//foo/myapp.gyp\"\n" 324 " gyp_file = \"//foo/myapp.gyp\"\n"
325 " sources = ...\n" 325 " sources = ...\n"
326 " }\n"; 326 " }\n";
327 327
328 int RunGyp(const std::vector<std::string>& args) { 328 int RunGyp(const std::vector<std::string>& args) {
329 const CommandLine* cmdline = CommandLine::ForCurrentProcess(); 329 base::ElapsedTimer timer;
330
331 base::TimeTicks begin_time = base::TimeTicks::Now();
332 330
333 // Deliberately leaked to avoid expensive process teardown. 331 // Deliberately leaked to avoid expensive process teardown.
334 Setup* setup_debug = new Setup; 332 Setup* setup_debug = new Setup;
335 if (!setup_debug->DoSetup()) 333 if (!setup_debug->DoSetup())
336 return 1; 334 return 1;
337 const char kIsDebug[] = "is_debug"; 335 const char kIsDebug[] = "is_debug";
338 336
339 SourceDir base_build_dir = setup_debug->build_settings().build_dir(); 337 SourceDir base_build_dir = setup_debug->build_settings().build_dir();
340 setup_debug->build_settings().SetBuildDir( 338 setup_debug->build_settings().SetBuildDir(
341 AppendDirSuffix(base_build_dir, ".Debug")); 339 AppendDirSuffix(base_build_dir, ".Debug"));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 std::pair<int, int> counts = 398 std::pair<int, int> counts =
401 WriteGypFiles(setup_debug, setup_release, 399 WriteGypFiles(setup_debug, setup_release,
402 setup_host_debug, setup_host_release, 400 setup_host_debug, setup_host_release,
403 setup_debug64, setup_release64, 401 setup_debug64, setup_release64,
404 &err); 402 &err);
405 if (err.has_error()) { 403 if (err.has_error()) {
406 err.PrintToStdout(); 404 err.PrintToStdout();
407 return 1; 405 return 1;
408 } 406 }
409 407
410 // Timing info. 408 base::TimeDelta elapsed_time = timer.Elapsed();
411 base::TimeTicks end_time = base::TimeTicks::Now(); 409
412 if (!cmdline->HasSwitch(kSwitchQuiet)) { 410 if (!CommandLine::ForCurrentProcess()->HasSwitch(kSwitchQuiet)) {
413 OutputString("Done. ", DECORATION_GREEN); 411 OutputString("Done. ", DECORATION_GREEN);
414 412
415 std::string stats = "Wrote " + 413 std::string stats = "Wrote " +
416 base::IntToString(counts.first) + " targets to " + 414 base::IntToString(counts.first) + " targets to " +
417 base::IntToString(counts.second) + " GYP files read from " + 415 base::IntToString(counts.second) + " GYP files read from " +
418 base::IntToString( 416 base::IntToString(
419 setup_debug->scheduler().input_file_manager()->GetInputFileCount()) 417 setup_debug->scheduler().input_file_manager()->GetInputFileCount())
420 + " GN files in " + 418 + " GN files in " +
421 base::IntToString((end_time - begin_time).InMilliseconds()) + "ms\n"; 419 base::IntToString(elapsed_time.InMilliseconds()) + "ms\n";
422 420
423 OutputString(stats); 421 OutputString(stats);
424 } 422 }
425 423
426 return 0; 424 return 0;
427 } 425 }
428 426
429 } // namespace commands 427 } // namespace commands
OLDNEW
« no previous file with comments | « tools/gn/command_gen.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698