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

Side by Side Diff: chrome/test/perf/url_parse_perftest.cc

Issue 23985006: base: Split logging functions and PerfTimeLogger out of perftimer.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix visitedlink Created 7 years, 3 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 | « base/test/perftimer.h ('k') | chrome_frame/test/perf/chrome_frame_perftest.h » ('j') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "base/test/perftimer.h" 5 #include "base/test/perf_time_logger.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 #include "url/gurl.h" 7 #include "url/gurl.h"
8 #include "url/url_canon.h" 8 #include "url/url_canon.h"
9 #include "url/url_canon_stdstring.h" 9 #include "url/url_canon_stdstring.h"
10 #include "url/url_parse.h" 10 #include "url/url_parse.h"
11 11
12 // TODO(darin): chrome code should not depend on WebCore innards 12 // TODO(darin): chrome code should not depend on WebCore innards
13 #if 0 13 #if 0
14 #pragma warning(push, 0) 14 #pragma warning(push, 0)
15 15
16 // This is because we have multiple headers called "CString.h" and KURL.cpp 16 // This is because we have multiple headers called "CString.h" and KURL.cpp
17 // can grab the wrong one. 17 // can grab the wrong one.
18 #include "webkit/third_party/WebCore/platform/CString.h" 18 #include "webkit/third_party/WebCore/platform/CString.h"
19 19
20 #define KURL WebKitKURL 20 #define KURL WebKitKURL
21 #include "KURL.cpp" 21 #include "KURL.cpp"
22 #include "KURL.h" 22 #include "KURL.h"
23 #pragma warning(pop) 23 #pragma warning(pop)
24 24
25 TEST(URLParse, FullURL) { 25 TEST(URLParse, FullURL) {
26 const char url[] = "http://me:pass@host/foo/bar.html;param?query=yes#ref"; 26 const char url[] = "http://me:pass@host/foo/bar.html;param?query=yes#ref";
27 int url_len = static_cast<int>(strlen(url)); 27 int url_len = static_cast<int>(strlen(url));
28 28
29 url_parse::Parsed parsed; 29 url_parse::Parsed parsed;
30 PerfTimeLogger timer("Full_URL_Parse_AMillion"); 30 base::PerfTimeLogger timer("Full_URL_Parse_AMillion");
31 31
32 for (int i = 0; i < 1000000; i++) 32 for (int i = 0; i < 1000000; i++)
33 url_parse::ParseStandardURL(url, url_len, &parsed); 33 url_parse::ParseStandardURL(url, url_len, &parsed);
34 timer.Done(); 34 timer.Done();
35 } 35 }
36 36
37 namespace { 37 namespace {
38 38
39 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"; 39 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";
40 int typical_url1_len = static_cast<int>(strlen(typical_url1)); 40 int typical_url1_len = static_cast<int>(strlen(typical_url1));
41 41
42 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=2144880 915&sr=8-2"; 42 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=2144880 915&sr=8-2";
43 int typical_url2_len = static_cast<int>(strlen(typical_url2)); 43 int typical_url2_len = static_cast<int>(strlen(typical_url2));
44 44
45 const char typical_url3[] = "http://store.apple.com/1-800-MY-APPLE/WebObjects/Ap pleStore.woa/wa/RSLID?nnmm=browse&mco=578E9744&node=home/desktop/mac_pro"; 45 const char typical_url3[] = "http://store.apple.com/1-800-MY-APPLE/WebObjects/Ap pleStore.woa/wa/RSLID?nnmm=browse&mco=578E9744&node=home/desktop/mac_pro";
46 int typical_url3_len = static_cast<int>(strlen(typical_url3)); 46 int typical_url3_len = static_cast<int>(strlen(typical_url3));
47 47
48 } // namespace 48 } // namespace
49 49
50 TEST(URLParse, TypicalURLParse) { 50 TEST(URLParse, TypicalURLParse) {
51 url_parse::Parsed parsed1; 51 url_parse::Parsed parsed1;
52 url_parse::Parsed parsed2; 52 url_parse::Parsed parsed2;
53 url_parse::Parsed parsed3; 53 url_parse::Parsed parsed3;
54 54
55 // Do this 1/3 of a million times since we do 3 different URLs. 55 // Do this 1/3 of a million times since we do 3 different URLs.
56 PerfTimeLogger parse_timer("Typical_URL_Parse_AMillion"); 56 base::PerfTimeLogger parse_timer("Typical_URL_Parse_AMillion");
57 for (int i = 0; i < 333333; i++) { 57 for (int i = 0; i < 333333; i++) {
58 url_parse::ParseStandardURL(typical_url1, typical_url1_len, &parsed1); 58 url_parse::ParseStandardURL(typical_url1, typical_url1_len, &parsed1);
59 url_parse::ParseStandardURL(typical_url2, typical_url2_len, &parsed2); 59 url_parse::ParseStandardURL(typical_url2, typical_url2_len, &parsed2);
60 url_parse::ParseStandardURL(typical_url3, typical_url3_len, &parsed3); 60 url_parse::ParseStandardURL(typical_url3, typical_url3_len, &parsed3);
61 } 61 }
62 parse_timer.Done(); 62 parse_timer.Done();
63 } 63 }
64 64
65 // Includes both parsing and canonicalization with no mallocs. 65 // Includes both parsing and canonicalization with no mallocs.
66 TEST(URLParse, TypicalURLParseCanon) { 66 TEST(URLParse, TypicalURLParseCanon) {
67 url_parse::Parsed parsed1; 67 url_parse::Parsed parsed1;
68 url_parse::Parsed parsed2; 68 url_parse::Parsed parsed2;
69 url_parse::Parsed parsed3; 69 url_parse::Parsed parsed3;
70 70
71 PerfTimeLogger canon_timer("Typical_Parse_Canon_AMillion"); 71 base::PerfTimeLogger canon_timer("Typical_Parse_Canon_AMillion");
72 url_parse::Parsed out_parsed; 72 url_parse::Parsed out_parsed;
73 url_canon::RawCanonOutput<1024> output; 73 url_canon::RawCanonOutput<1024> output;
74 for (int i = 0; i < 333333; i++) { // divide by 3 so we get 1M 74 for (int i = 0; i < 333333; i++) { // divide by 3 so we get 1M
75 url_parse::ParseStandardURL(typical_url1, typical_url1_len, &parsed1); 75 url_parse::ParseStandardURL(typical_url1, typical_url1_len, &parsed1);
76 output.set_length(0); 76 output.set_length(0);
77 url_canon::CanonicalizeStandardURL(typical_url1, typical_url1_len, parsed1, 77 url_canon::CanonicalizeStandardURL(typical_url1, typical_url1_len, parsed1,
78 NULL, &output, &out_parsed); 78 NULL, &output, &out_parsed);
79 79
80 url_parse::ParseStandardURL(typical_url2, typical_url2_len, &parsed2); 80 url_parse::ParseStandardURL(typical_url2, typical_url2_len, &parsed2);
81 output.set_length(0); 81 output.set_length(0);
82 url_canon::CanonicalizeStandardURL(typical_url2, typical_url2_len, parsed2, 82 url_canon::CanonicalizeStandardURL(typical_url2, typical_url2_len, parsed2,
83 NULL, &output, &out_parsed); 83 NULL, &output, &out_parsed);
84 84
85 url_parse::ParseStandardURL(typical_url3, typical_url3_len, &parsed3); 85 url_parse::ParseStandardURL(typical_url3, typical_url3_len, &parsed3);
86 output.set_length(0); 86 output.set_length(0);
87 url_canon::CanonicalizeStandardURL(typical_url3, typical_url3_len, parsed3, 87 url_canon::CanonicalizeStandardURL(typical_url3, typical_url3_len, parsed3,
88 NULL, &output, &out_parsed); 88 NULL, &output, &out_parsed);
89 } 89 }
90 canon_timer.Done(); 90 canon_timer.Done();
91 } 91 }
92 92
93 // Includes both parsing and canonicalization, and mallocs for the output. 93 // Includes both parsing and canonicalization, and mallocs for the output.
94 TEST(URLParse, TypicalURLParseCanonStdString) { 94 TEST(URLParse, TypicalURLParseCanonStdString) {
95 url_parse::Parsed parsed1; 95 url_parse::Parsed parsed1;
96 url_parse::Parsed parsed2; 96 url_parse::Parsed parsed2;
97 url_parse::Parsed parsed3; 97 url_parse::Parsed parsed3;
98 98
99 PerfTimeLogger canon_timer("Typical_Parse_Canon_AMillion"); 99 base::PerfTimeLogger canon_timer("Typical_Parse_Canon_AMillion");
100 url_parse::Parsed out_parsed; 100 url_parse::Parsed out_parsed;
101 for (int i = 0; i < 333333; i++) { // divide by 3 so we get 1M 101 for (int i = 0; i < 333333; i++) { // divide by 3 so we get 1M
102 url_parse::ParseStandardURL(typical_url1, typical_url1_len, &parsed1); 102 url_parse::ParseStandardURL(typical_url1, typical_url1_len, &parsed1);
103 std::string out1; 103 std::string out1;
104 url_canon::StdStringCanonOutput output1(&out1); 104 url_canon::StdStringCanonOutput output1(&out1);
105 url_canon::CanonicalizeStandardURL(typical_url1, typical_url1_len, parsed1, 105 url_canon::CanonicalizeStandardURL(typical_url1, typical_url1_len, parsed1,
106 NULL, &output1, &out_parsed); 106 NULL, &output1, &out_parsed);
107 107
108 url_parse::ParseStandardURL(typical_url2, typical_url2_len, &parsed2); 108 url_parse::ParseStandardURL(typical_url2, typical_url2_len, &parsed2);
109 std::string out2; 109 std::string out2;
110 url_canon::StdStringCanonOutput output2(&out2); 110 url_canon::StdStringCanonOutput output2(&out2);
111 url_canon::CanonicalizeStandardURL(typical_url2, typical_url2_len, parsed2, 111 url_canon::CanonicalizeStandardURL(typical_url2, typical_url2_len, parsed2,
112 NULL, &output2, &out_parsed); 112 NULL, &output2, &out_parsed);
113 113
114 url_parse::ParseStandardURL(typical_url3, typical_url3_len, &parsed3); 114 url_parse::ParseStandardURL(typical_url3, typical_url3_len, &parsed3);
115 std::string out3; 115 std::string out3;
116 url_canon::StdStringCanonOutput output3(&out3); 116 url_canon::StdStringCanonOutput output3(&out3);
117 url_canon::CanonicalizeStandardURL(typical_url3, typical_url3_len, parsed3, 117 url_canon::CanonicalizeStandardURL(typical_url3, typical_url3_len, parsed3,
118 NULL, &output3, &out_parsed); 118 NULL, &output3, &out_parsed);
119 } 119 }
120 canon_timer.Done(); 120 canon_timer.Done();
121 } 121 }
122 122
123 TEST(URLParse, GURL) { 123 TEST(URLParse, GURL) {
124 // Don't want to time creating the input strings. 124 // Don't want to time creating the input strings.
125 std::string stdurl1(typical_url1); 125 std::string stdurl1(typical_url1);
126 std::string stdurl2(typical_url2); 126 std::string stdurl2(typical_url2);
127 std::string stdurl3(typical_url3); 127 std::string stdurl3(typical_url3);
128 128
129 PerfTimeLogger gurl_timer("Typical_GURL_AMillion"); 129 base::PerfTimeLogger gurl_timer("Typical_GURL_AMillion");
130 for (int i = 0; i < 333333; i++) { // divide by 3 so we get 1M 130 for (int i = 0; i < 333333; i++) { // divide by 3 so we get 1M
131 GURL gurl1(stdurl1); 131 GURL gurl1(stdurl1);
132 GURL gurl2(stdurl2); 132 GURL gurl2(stdurl2);
133 GURL gurl3(stdurl3); 133 GURL gurl3(stdurl3);
134 } 134 }
135 gurl_timer.Done(); 135 gurl_timer.Done();
136 } 136 }
137 137
138 // TODO(darin): chrome code should not depend on WebCore innards 138 // TODO(darin): chrome code should not depend on WebCore innards
139 TEST(URLParse, KURL) { 139 TEST(URLParse, KURL) {
140 PerfTimeLogger timer_kurl("Typical_KURL_AMillion"); 140 base::PerfTimeLogger timer_kurl("Typical_KURL_AMillion");
141 for (int i = 0; i < 333333; i++) { // divide by 3 so we get 1M 141 for (int i = 0; i < 333333; i++) { // divide by 3 so we get 1M
142 WebCore::WebKitKURL kurl1(typical_url1); 142 WebCore::WebKitKURL kurl1(typical_url1);
143 WebCore::WebKitKURL kurl2(typical_url2); 143 WebCore::WebKitKURL kurl2(typical_url2);
144 WebCore::WebKitKURL kurl3(typical_url3); 144 WebCore::WebKitKURL kurl3(typical_url3);
145 } 145 }
146 timer_kurl.Done(); 146 timer_kurl.Done();
147 } 147 }
148 148
149 #endif 149 #endif
OLDNEW
« no previous file with comments | « base/test/perftimer.h ('k') | chrome_frame/test/perf/chrome_frame_perftest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698