OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/perftimer.h" | 5 #include "base/perftimer.h" |
6 #include "net/base/mock_host_resolver.h" | 6 #include "net/base/mock_host_resolver.h" |
7 #include "net/proxy/proxy_resolver_js_bindings.h" | 7 #include "net/proxy/proxy_resolver_js_bindings.h" |
8 #include "net/proxy/proxy_resolver_v8.h" | 8 #include "net/proxy/proxy_resolver_v8.h" |
9 #include "net/url_request/url_request_unittest.h" | 9 #include "net/url_request/url_request_unittest.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 } else { | 102 } else { |
103 LoadPacScriptIntoResolver(script_name); | 103 LoadPacScriptIntoResolver(script_name); |
104 } | 104 } |
105 | 105 |
106 // Do a query to warm things up. In the case of internal-fetch proxy | 106 // Do a query to warm things up. In the case of internal-fetch proxy |
107 // resolvers, the first resolve will be slow since it has to download | 107 // resolvers, the first resolve will be slow since it has to download |
108 // the PAC script. | 108 // the PAC script. |
109 { | 109 { |
110 net::ProxyInfo proxy_info; | 110 net::ProxyInfo proxy_info; |
111 int result = resolver_->GetProxyForURL( | 111 int result = resolver_->GetProxyForURL( |
112 GURL("http://www.warmup.com"), &proxy_info, NULL, NULL, NULL); | 112 GURL("http://www.warmup.com"), &proxy_info, NULL, NULL, |
| 113 net::BoundNetLog()); |
113 ASSERT_EQ(net::OK, result); | 114 ASSERT_EQ(net::OK, result); |
114 } | 115 } |
115 | 116 |
116 // Start the perf timer. | 117 // Start the perf timer. |
117 std::string perf_test_name = resolver_name_ + "_" + script_name; | 118 std::string perf_test_name = resolver_name_ + "_" + script_name; |
118 PerfTimeLogger timer(perf_test_name.c_str()); | 119 PerfTimeLogger timer(perf_test_name.c_str()); |
119 | 120 |
120 for (int i = 0; i < kNumIterations; ++i) { | 121 for (int i = 0; i < kNumIterations; ++i) { |
121 // Round-robin between URLs to resolve. | 122 // Round-robin between URLs to resolve. |
122 const PacQuery& query = queries[i % queries_len]; | 123 const PacQuery& query = queries[i % queries_len]; |
123 | 124 |
124 // Resolve. | 125 // Resolve. |
125 net::ProxyInfo proxy_info; | 126 net::ProxyInfo proxy_info; |
126 int result = resolver_->GetProxyForURL(GURL(query.query_url), | 127 int result = resolver_->GetProxyForURL(GURL(query.query_url), |
127 &proxy_info, NULL, NULL, NULL); | 128 &proxy_info, NULL, NULL, |
| 129 net::BoundNetLog()); |
128 | 130 |
129 // Check that the result was correct. Note that ToPacString() and | 131 // Check that the result was correct. Note that ToPacString() and |
130 // ASSERT_EQ() are fast, so they won't skew the results. | 132 // ASSERT_EQ() are fast, so they won't skew the results. |
131 ASSERT_EQ(net::OK, result); | 133 ASSERT_EQ(net::OK, result); |
132 ASSERT_EQ(query.expected_result, proxy_info.ToPacString()); | 134 ASSERT_EQ(query.expected_result, proxy_info.ToPacString()); |
133 } | 135 } |
134 | 136 |
135 // Print how long the test ran for. | 137 // Print how long the test ran for. |
136 timer.Done(); | 138 timer.Done(); |
137 } | 139 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 #endif | 190 #endif |
189 | 191 |
190 TEST(ProxyResolverPerfTest, ProxyResolverV8) { | 192 TEST(ProxyResolverPerfTest, ProxyResolverV8) { |
191 net::ProxyResolverJSBindings* js_bindings = | 193 net::ProxyResolverJSBindings* js_bindings = |
192 net::ProxyResolverJSBindings::CreateDefault(new net::MockHostResolver); | 194 net::ProxyResolverJSBindings::CreateDefault(new net::MockHostResolver); |
193 | 195 |
194 net::ProxyResolverV8 resolver(js_bindings); | 196 net::ProxyResolverV8 resolver(js_bindings); |
195 PacPerfSuiteRunner runner(&resolver, "ProxyResolverV8"); | 197 PacPerfSuiteRunner runner(&resolver, "ProxyResolverV8"); |
196 runner.RunAllTests(); | 198 runner.RunAllTests(); |
197 } | 199 } |
OLD | NEW |