OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <utility> | 5 #include <utility> |
6 | 6 |
7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 } else { | 126 } else { |
127 resolver = LoadPacScriptAndCreateResolver(script_name); | 127 resolver = LoadPacScriptAndCreateResolver(script_name); |
128 } | 128 } |
129 ASSERT_TRUE(resolver); | 129 ASSERT_TRUE(resolver); |
130 | 130 |
131 // Do a query to warm things up. In the case of internal-fetch proxy | 131 // Do a query to warm things up. In the case of internal-fetch proxy |
132 // resolvers, the first resolve will be slow since it has to download | 132 // resolvers, the first resolve will be slow since it has to download |
133 // the PAC script. | 133 // the PAC script. |
134 { | 134 { |
135 ProxyInfo proxy_info; | 135 ProxyInfo proxy_info; |
136 int result = | 136 int result = resolver->GetProxyForURL(GURL("http://www.warmup.com"), |
137 resolver->GetProxyForURL(GURL("http://www.warmup.com"), &proxy_info, | 137 &proxy_info, CompletionCallback(), |
138 CompletionCallback(), NULL, BoundNetLog()); | 138 NULL, NetLogWithSource()); |
139 ASSERT_THAT(result, IsOk()); | 139 ASSERT_THAT(result, IsOk()); |
140 } | 140 } |
141 | 141 |
142 // Start the perf timer. | 142 // Start the perf timer. |
143 std::string perf_test_name = resolver_name_ + "_" + script_name; | 143 std::string perf_test_name = resolver_name_ + "_" + script_name; |
144 base::PerfTimeLogger timer(perf_test_name.c_str()); | 144 base::PerfTimeLogger timer(perf_test_name.c_str()); |
145 | 145 |
146 for (int i = 0; i < kNumIterations; ++i) { | 146 for (int i = 0; i < kNumIterations; ++i) { |
147 // Round-robin between URLs to resolve. | 147 // Round-robin between URLs to resolve. |
148 const PacQuery& query = queries[i % queries_len]; | 148 const PacQuery& query = queries[i % queries_len]; |
149 | 149 |
150 // Resolve. | 150 // Resolve. |
151 ProxyInfo proxy_info; | 151 ProxyInfo proxy_info; |
152 int result = | 152 int result = resolver->GetProxyForURL(GURL(query.query_url), &proxy_info, |
153 resolver->GetProxyForURL(GURL(query.query_url), &proxy_info, | 153 CompletionCallback(), NULL, |
154 CompletionCallback(), NULL, BoundNetLog()); | 154 NetLogWithSource()); |
155 | 155 |
156 // Check that the result was correct. Note that ToPacString() and | 156 // Check that the result was correct. Note that ToPacString() and |
157 // ASSERT_EQ() are fast, so they won't skew the results. | 157 // ASSERT_EQ() are fast, so they won't skew the results. |
158 ASSERT_THAT(result, IsOk()); | 158 ASSERT_THAT(result, IsOk()); |
159 ASSERT_EQ(query.expected_result, proxy_info.ToPacString()); | 159 ASSERT_EQ(query.expected_result, proxy_info.ToPacString()); |
160 } | 160 } |
161 | 161 |
162 // Print how long the test ran for. | 162 // Print how long the test ran for. |
163 timer.Done(); | 163 timer.Done(); |
164 } | 164 } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 class ProxyResolverV8Wrapper : public ProxyResolver { | 232 class ProxyResolverV8Wrapper : public ProxyResolver { |
233 public: | 233 public: |
234 ProxyResolverV8Wrapper(std::unique_ptr<ProxyResolverV8> resolver, | 234 ProxyResolverV8Wrapper(std::unique_ptr<ProxyResolverV8> resolver, |
235 std::unique_ptr<MockJSBindings> bindings) | 235 std::unique_ptr<MockJSBindings> bindings) |
236 : resolver_(std::move(resolver)), bindings_(std::move(bindings)) {} | 236 : resolver_(std::move(resolver)), bindings_(std::move(bindings)) {} |
237 | 237 |
238 int GetProxyForURL(const GURL& url, | 238 int GetProxyForURL(const GURL& url, |
239 ProxyInfo* results, | 239 ProxyInfo* results, |
240 const CompletionCallback& /*callback*/, | 240 const CompletionCallback& /*callback*/, |
241 RequestHandle* /*request*/, | 241 RequestHandle* /*request*/, |
242 const BoundNetLog& net_log) override { | 242 const NetLogWithSource& net_log) override { |
243 return resolver_->GetProxyForURL(url, results, bindings_.get()); | 243 return resolver_->GetProxyForURL(url, results, bindings_.get()); |
244 } | 244 } |
245 | 245 |
246 void CancelRequest(RequestHandle request) override { NOTREACHED(); } | 246 void CancelRequest(RequestHandle request) override { NOTREACHED(); } |
247 | 247 |
248 LoadState GetLoadState(RequestHandle request) const override { | 248 LoadState GetLoadState(RequestHandle request) const override { |
249 NOTREACHED(); | 249 NOTREACHED(); |
250 return LOAD_STATE_IDLE; | 250 return LOAD_STATE_IDLE; |
251 } | 251 } |
252 | 252 |
(...skipping 30 matching lines...) Expand all Loading... |
283 TEST(ProxyResolverPerfTest, ProxyResolverV8) { | 283 TEST(ProxyResolverPerfTest, ProxyResolverV8) { |
284 base::MessageLoop message_loop; | 284 base::MessageLoop message_loop; |
285 ProxyResolverV8Factory factory; | 285 ProxyResolverV8Factory factory; |
286 PacPerfSuiteRunner runner(&factory, "ProxyResolverV8"); | 286 PacPerfSuiteRunner runner(&factory, "ProxyResolverV8"); |
287 runner.RunAllTests(); | 287 runner.RunAllTests(); |
288 } | 288 } |
289 | 289 |
290 } // namespace | 290 } // namespace |
291 | 291 |
292 } // namespace net | 292 } // namespace net |
OLD | NEW |