summaryrefslogtreecommitdiffstats
path: root/chrome/test/perf
diff options
context:
space:
mode:
authorinitial.commit <initial.commit@0039d316-1c4b-4281-b951-d872f2087c98>2008-07-26 23:55:29 +0000
committerinitial.commit <initial.commit@0039d316-1c4b-4281-b951-d872f2087c98>2008-07-26 23:55:29 +0000
commit09911bf300f1a419907a9412154760efd0b7abc3 (patch)
treef131325fb4e2ad12c6d3504ab75b16dd92facfed /chrome/test/perf
parent586acc5fe142f498261f52c66862fa417c3d52d2 (diff)
downloadchromium_src-09911bf300f1a419907a9412154760efd0b7abc3.zip
chromium_src-09911bf300f1a419907a9412154760efd0b7abc3.tar.gz
chromium_src-09911bf300f1a419907a9412154760efd0b7abc3.tar.bz2
Add chrome to the repository.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/perf')
-rw-r--r--chrome/test/perf/mem_usage.cc98
-rw-r--r--chrome/test/perf/mem_usage.h64
-rw-r--r--chrome/test/perf/perftests.cc77
-rw-r--r--chrome/test/perf/perftests.vcproj207
-rw-r--r--chrome/test/perf/url_parse_perftest.cc175
5 files changed, 621 insertions, 0 deletions
diff --git a/chrome/test/perf/mem_usage.cc b/chrome/test/perf/mem_usage.cc
new file mode 100644
index 0000000..c8ec78c
--- /dev/null
+++ b/chrome/test/perf/mem_usage.cc
@@ -0,0 +1,98 @@
+// Copyright 2008, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include <windows.h>
+#include <psapi.h>
+
+#include "base/basictypes.h"
+#include "base/process_util.h"
+#include "chrome/common/chrome_constants.h"
+#include "chrome/common/chrome_process_filter.h"
+#include "chrome/test/perf/mem_usage.h"
+
+bool GetMemoryInfo(uint32 process_id,
+ size_t *peak_virtual_size,
+ size_t *current_virtual_size,
+ size_t *peak_working_set_size,
+ size_t *current_working_set_size) {
+
+ if (!peak_virtual_size || !current_virtual_size)
+ return false;
+
+ HANDLE process_handle = OpenProcess(PROCESS_QUERY_INFORMATION |
+ PROCESS_VM_READ,
+ FALSE, process_id);
+ if (!process_handle)
+ return false;
+
+ PROCESS_MEMORY_COUNTERS_EX pmc;
+ bool result = false;
+ if (GetProcessMemoryInfo(process_handle,
+ reinterpret_cast<PPROCESS_MEMORY_COUNTERS>(&pmc),
+ sizeof(pmc))) {
+ *peak_virtual_size = pmc.PeakPagefileUsage;
+ *current_virtual_size = pmc.PagefileUsage;
+ *peak_working_set_size = pmc.PeakWorkingSetSize;
+ *current_working_set_size = pmc.WorkingSetSize;
+ result = true;
+ }
+
+ CloseHandle(process_handle);
+ return result;
+}
+
+void PrintChromeMemoryUsageInfo() {
+ printf("\n");
+ BrowserProcessFilter chrome_filter;
+ process_util::NamedProcessIterator
+ chrome_process_itr(chrome::kBrowserProcessExecutableName, &chrome_filter);
+
+ const PROCESSENTRY32* chrome_entry;
+ while(chrome_entry = chrome_process_itr.NextProcessEntry()) {
+ uint32 pid = chrome_entry->th32ProcessID;
+ size_t peak_virtual_size;
+ size_t current_virtual_size;
+ size_t peak_working_set_size;
+ size_t current_working_set_size;
+ if (GetMemoryInfo(pid, &peak_virtual_size, &current_virtual_size,
+ &peak_working_set_size, &current_working_set_size)) {
+ if (pid == chrome_filter.browser_process_id()) {
+ wprintf(L"browser_vm_peak = %d\n", peak_virtual_size);
+ wprintf(L"browser_vm_current = %d\n", current_virtual_size);
+ wprintf(L"browser_ws_peak = %d\n", peak_working_set_size);
+ wprintf(L"browser_ws_final = %d\n", current_working_set_size);
+ } else {
+ wprintf(L"render_vm_peak = %d\n", peak_virtual_size);
+ wprintf(L"render_vm_current = %d\n", current_virtual_size);
+ wprintf(L"render_ws_peak = %d\n", peak_working_set_size);
+ wprintf(L"render_ws_final = %d\n", current_working_set_size);
+ }
+ }
+ };
+}
diff --git a/chrome/test/perf/mem_usage.h b/chrome/test/perf/mem_usage.h
new file mode 100644
index 0000000..940a0d1
--- /dev/null
+++ b/chrome/test/perf/mem_usage.h
@@ -0,0 +1,64 @@
+// Copyright 2008, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef CHROME_TEST_PERF_MEM_USAGE_H__
+#define CHROME_TEST_PERF_MEM_USAGE_H__
+
+// Get memory information for the process with given process ID.
+//
+// The Windows psapi provides memory information of a process through structure
+// RPROCESS_MEMORY_COUNTERS_EX. Relevant fields are:
+// PagefileUsage: private (not shared) committed virtual space in process.
+// This is "VM Size" in task manager processes tab.
+// PeakPagefileUsage: peak value of PagefileUsage.
+// WorkingSetSize: physical memory allocated to process including shared pages.
+// This is "Memory Usage" in task manager processes tab.
+// Contrary to its name, this value is not much useful for
+// tracking the memory demand of an application.
+// PeakWorkingSetSize: peak value of WorkingSetSize.
+// This is "Peak Memory Usage" in task manager processes
+// tab.
+// PrivateUsage: The current amount of memory that cannot be shared with other
+// processes. Private bytes include memory that is committed and
+// marked MEM_PRIVATE, data that is not mapped, and executable
+// pages that have been written to. It usually gives the same
+// value as PagefileUsage. No equivalent part in task manager.
+//
+// The measurements we use are PagefileUsage (returned by current_virtual_size)
+// and PeakPagefileUsage (returned by peak_virtual_size), Working Set and
+// Peak working Set.
+bool GetMemoryInfo(uint32 process_id,
+ size_t *peak_virtual_size,
+ size_t *current_virtual_size,
+ size_t *peak_working_set_size,
+ size_t *current_working_set_size);
+
+// Get and print memory usage information for running chrome processes.
+void PrintChromeMemoryUsageInfo();
+#endif // CHROME_TEST_PERF_MEM_USAGE_H__
diff --git a/chrome/test/perf/perftests.cc b/chrome/test/perf/perftests.cc
new file mode 100644
index 0000000..c76bc69
--- /dev/null
+++ b/chrome/test/perf/perftests.cc
@@ -0,0 +1,77 @@
+// Copyright 2008, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "base/message_loop.h"
+#include "base/perftimer.h"
+#include "chrome/common/chrome_paths.cc"
+#include "testing/gtest/include/gtest/gtest.h"
+
+// TODO(darin): share code with base/run_all_perftests.cc
+
+int main(int argc, char **argv) {
+ chrome::RegisterPathProvider();
+ MessageLoop main_message_loop;
+
+ testing::InitGoogleTest(&argc, argv);
+
+ const char log_file_switch[] = "-o";
+ const char* log_filename = NULL;
+ for (int i = 1; i < argc; i++) {
+ if (strcmp(argv[i], log_file_switch) == 0) {
+ // found the switch for the log file, use the next arg
+ if (i >= argc - 1) {
+ fprintf(stderr, "Log file not specified");
+ return 1;
+ }
+ log_filename = argv[i + 1];
+ }
+ }
+ if (!log_filename) {
+ // use the default filename
+ log_filename = "perf_test.log";
+ }
+ printf("Using output file \"%s\" (change with %s <filename>)\n",
+ log_filename, log_file_switch);
+
+ if (!InitPerfLog(log_filename)) {
+ fprintf(stderr, "Unable to open log file\n");
+ return 1;
+ }
+
+ // Raise to high priority to have more precise measurements. Since we don't
+ // aim at 1% precision, it is not necessary to run at realtime level.
+ if (!IsDebuggerPresent()) {
+ SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
+ }
+
+ int result = RUN_ALL_TESTS();
+
+ FinalizePerfLog();
+ return result;
+}
diff --git a/chrome/test/perf/perftests.vcproj b/chrome/test/perf/perftests.vcproj
new file mode 100644
index 0000000..44435d5
--- /dev/null
+++ b/chrome/test/perf/perftests.vcproj
@@ -0,0 +1,207 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="perf_tests"
+ ProjectGUID="{9055E088-25C6-47FD-87D5-D9DD9FD75C9F}"
+ RootNamespace="perf_tests"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(SolutionDir)..\build\common.vsprops;$(SolutionDir)..\build\debug.vsprops;$(SolutionDir)..\third_party\icu38\build\using_icu.vsprops;$(SolutionDir)..\third_party\libxml\build\using_libxml.vsprops;$(SolutionDir)..\testing\using_gtest.vsprops"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="PERF_TEST;_CRT_RAND_S"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="shlwapi.lib rpcrt4.lib winmm.lib"
+ SubSystem="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(SolutionDir)..\build\common.vsprops;$(SolutionDir)..\build\release.vsprops;$(SolutionDir)..\third_party\icu38\build\using_icu.vsprops;$(SolutionDir)..\third_party\libxml\build\using_libxml.vsprops;$(SolutionDir)..\testing\using_gtest.vsprops"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="PERF_TEST;_CRT_RAND_S"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="shlwapi.lib rpcrt4.lib winmm.lib"
+ SubSystem="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="TestVisitedLink"
+ >
+ <File
+ RelativePath="..\..\browser\visitedlink_master.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\..\browser\visitedlink_perftest.cc"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Common"
+ >
+ <File
+ RelativePath=".\perftests.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\base\perftimer.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\test_file_util.cc"
+ >
+ </File>
+ <File
+ RelativePath="..\test_file_util.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="TestURLParser"
+ >
+ <File
+ RelativePath=".\url_parse_perftest.cc"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="TestJSONSerializer"
+ >
+ <File
+ RelativePath="..\..\common\json_value_serializer_perftest.cc"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="TestSafeBrowsing"
+ >
+ <File
+ RelativePath="..\..\browser\safe_browsing\database_perftest.cc"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/chrome/test/perf/url_parse_perftest.cc b/chrome/test/perf/url_parse_perftest.cc
new file mode 100644
index 0000000..2dc6153
--- /dev/null
+++ b/chrome/test/perf/url_parse_perftest.cc
@@ -0,0 +1,175 @@
+// Copyright 2008, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "base/perftimer.h"
+#include "googleurl/src/gurl.h"
+#include "googleurl/src/url_canon.h"
+#include "googleurl/src/url_canon_stdstring.h"
+#include "googleurl/src/url_parse.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+// TODO(darin): chrome code should not depend on WebCore innards
+#if 0
+#pragma warning(push, 0)
+
+// This is because we have multiple headers called "CString.h" and KURL.cpp
+// can grab the wrong one.
+#include "webkit/third_party/WebCore/platform/CString.h"
+
+#undef USE_GOOGLE_URL_LIBRARY
+#define KURL WebKitKURL
+#include "KURL.h"
+#include "KURL.cpp"
+#pragma warning(pop)
+
+TEST(URLParse, FullURL) {
+ const char url[] = "http://me:pass@host/foo/bar.html;param?query=yes#ref";
+ int url_len = static_cast<int>(strlen(url));
+
+ url_parse::Parsed parsed;
+ PerfTimeLogger timer("Full_URL_Parse_AMillion");
+
+ for (int i = 0; i < 1000000; i++)
+ url_parse::ParseStandardURL(url, url_len, &parsed);
+ timer.Done();
+}
+
+namespace {
+
+const char typical_url1[] = "http://www.google.com/search?q=url+parsing&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a";
+int typical_url1_len = static_cast<int>(strlen(typical_url1));
+
+const char typical_url2[] = "http://www.amazon.com/Stephen-King-Thrillers-Horror-People/dp/0766012336/ref=sr_1_2/133-4144931-4505264?ie=UTF8&s=books&qid=2144880915&sr=8-2";
+int typical_url2_len = static_cast<int>(strlen(typical_url2));
+
+const char typical_url3[] = "http://store.apple.com/1-800-MY-APPLE/WebObjects/AppleStore.woa/wa/RSLID?nnmm=browse&mco=578E9744&node=home/desktop/mac_pro";
+int typical_url3_len = static_cast<int>(strlen(typical_url3));
+
+}
+
+TEST(URLParse, TypicalURLParse) {
+ url_parse::Parsed parsed1;
+ url_parse::Parsed parsed2;
+ url_parse::Parsed parsed3;
+
+ // Do this 1/3 of a million times since we do 3 different URLs.
+ PerfTimeLogger parse_timer("Typical_URL_Parse_AMillion");
+ for (int i = 0; i < 333333; i++) {
+ url_parse::ParseStandardURL(typical_url1, typical_url1_len, &parsed1);
+ url_parse::ParseStandardURL(typical_url2, typical_url2_len, &parsed2);
+ url_parse::ParseStandardURL(typical_url3, typical_url3_len, &parsed3);
+ }
+ parse_timer.Done();
+}
+
+// Includes both parsing and canonicalization with no mallocs.
+TEST(URLParse, TypicalURLParseCanon) {
+ url_parse::Parsed parsed1;
+ url_parse::Parsed parsed2;
+ url_parse::Parsed parsed3;
+
+ PerfTimeLogger canon_timer("Typical_Parse_Canon_AMillion");
+ url_parse::Parsed out_parsed;
+ url_canon::RawCanonOutput<1024> output;
+ for (int i = 0; i < 333333; i++) { // divide by 3 so we get 1M
+ url_parse::ParseStandardURL(typical_url1, typical_url1_len, &parsed1);
+ output.set_length(0);
+ url_canon::CanonicalizeStandardURL(typical_url1, typical_url1_len, parsed1,
+ NULL, &output, &out_parsed);
+
+ url_parse::ParseStandardURL(typical_url2, typical_url2_len, &parsed2);
+ output.set_length(0);
+ url_canon::CanonicalizeStandardURL(typical_url2, typical_url2_len, parsed2,
+ NULL, &output, &out_parsed);
+
+ url_parse::ParseStandardURL(typical_url3, typical_url3_len, &parsed3);
+ output.set_length(0);
+ url_canon::CanonicalizeStandardURL(typical_url3, typical_url3_len, parsed3,
+ NULL, &output, &out_parsed);
+ }
+ canon_timer.Done();
+}
+
+// Includes both parsing and canonicalization, and mallocs for the output.
+TEST(URLParse, TypicalURLParseCanonStdString) {
+ url_parse::Parsed parsed1;
+ url_parse::Parsed parsed2;
+ url_parse::Parsed parsed3;
+
+ PerfTimeLogger canon_timer("Typical_Parse_Canon_AMillion");
+ url_parse::Parsed out_parsed;
+ for (int i = 0; i < 333333; i++) { // divide by 3 so we get 1M
+ url_parse::ParseStandardURL(typical_url1, typical_url1_len, &parsed1);
+ std::string out1;
+ url_canon::StdStringCanonOutput output1(&out1);
+ url_canon::CanonicalizeStandardURL(typical_url1, typical_url1_len, parsed1,
+ NULL, &output1, &out_parsed);
+
+ url_parse::ParseStandardURL(typical_url2, typical_url2_len, &parsed2);
+ std::string out2;
+ url_canon::StdStringCanonOutput output2(&out2);
+ url_canon::CanonicalizeStandardURL(typical_url2, typical_url2_len, parsed2,
+ NULL, &output2, &out_parsed);
+
+ url_parse::ParseStandardURL(typical_url3, typical_url3_len, &parsed3);
+ std::string out3;
+ url_canon::StdStringCanonOutput output3(&out3);
+ url_canon::CanonicalizeStandardURL(typical_url3, typical_url3_len, parsed3,
+ NULL, &output3, &out_parsed);
+ }
+ canon_timer.Done();
+}
+
+TEST(URLParse, GURL) {
+ // Don't want to time creating the input strings.
+ std::string stdurl1(typical_url1);
+ std::string stdurl2(typical_url2);
+ std::string stdurl3(typical_url3);
+
+ PerfTimeLogger gurl_timer("Typical_GURL_AMillion");
+ for (int i = 0; i < 333333; i++) { // divide by 3 so we get 1M
+ GURL gurl1(stdurl1);
+ GURL gurl2(stdurl2);
+ GURL gurl3(stdurl3);
+ }
+ gurl_timer.Done();
+}
+
+// TODO(darin): chrome code should not depend on WebCore innards
+TEST(URLParse, KURL) {
+ PerfTimeLogger timer_kurl("Typical_KURL_AMillion");
+ for (int i = 0; i < 333333; i++) { // divide by 3 so we get 1M
+ WebCore::WebKitKURL kurl1(typical_url1);
+ WebCore::WebKitKURL kurl2(typical_url2);
+ WebCore::WebKitKURL kurl3(typical_url3);
+ }
+ timer_kurl.Done();
+}
+
+#endif \ No newline at end of file