1 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 """Command for measuring how long pages take to load in a browser.
8 1. The command_line package from tools/site_compare
9 2. Either the IE BHO or Firefox extension (or both)
12 1. Build the IE BHO, or call regsvr32 on a prebuilt binary
13 2. Add a file called "measurepageloadtimeextension@google.com" to
14 the default Firefox profile directory under extensions, containing
15 the path to the Firefox extension root
17 Invoke with the command line arguments as documented within
24 from drivers
import windowing
25 from utils
import browser_iterate
27 def CreateCommand(cmdline
):
28 """Inserts the command and arguments into a command line for parsing."""
29 cmd
= cmdline
.AddCommand(
31 "Measures how long a series of URLs takes to load in one or more browsers.",
35 browser_iterate
.SetupIterationCommandLine(cmd
)
37 ["-log", "--logfile"], "File to write output", type="string", required
=True)
40 def ExecuteMeasure(command
):
41 """Executes the Measure command."""
43 def LogResult(url
, proc
, wnd
, result
):
44 """Write the result of the browse to the log file."""
45 log_file
.write(result
)
47 log_file
= open(command
["--logfile"], "w")
49 browser_iterate
.Iterate(command
, LogResult
)
51 # Close the log file and return. We're done.