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

Side by Side Diff: net/proxy/proxy_resolver_perftest.cc

Issue 11885009: Improve performance of proxy resolver by tracing DNS dependencies. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase off trunk Created 7 years, 11 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
OLDNEW
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 "base/base_paths.h" 5 #include "base/base_paths.h"
6 #include "base/compiler_specific.h" 6 #include "base/compiler_specific.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/perftimer.h" 9 #include "base/perftimer.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "net/base/mock_host_resolver.h" 11 #include "net/base/mock_host_resolver.h"
12 #include "net/base/net_errors.h" 12 #include "net/base/net_errors.h"
13 #include "net/proxy/proxy_info.h" 13 #include "net/proxy/proxy_info.h"
14 #include "net/proxy/proxy_resolver_js_bindings.h"
15 #include "net/proxy/proxy_resolver_v8.h" 14 #include "net/proxy/proxy_resolver_v8.h"
16 #include "net/proxy/sync_host_resolver.h"
17 #include "net/test/test_server.h" 15 #include "net/test/test_server.h"
18 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
19 17
20 #if defined(OS_WIN) 18 #if defined(OS_WIN)
21 #include "net/proxy/proxy_resolver_winhttp.h" 19 #include "net/proxy/proxy_resolver_winhttp.h"
22 #elif defined(OS_MACOSX) 20 #elif defined(OS_MACOSX)
23 #include "net/proxy/proxy_resolver_mac.h" 21 #include "net/proxy/proxy_resolver_mac.h"
24 #endif 22 #endif
25 23
26 class MockSyncHostResolver : public net::SyncHostResolver {
27 public:
28 virtual int Resolve(const net::HostResolver::RequestInfo& info,
29 net::AddressList* addresses,
30 const net::BoundNetLog& net_log) OVERRIDE {
31 return net::ERR_NAME_NOT_RESOLVED;
32 }
33
34 virtual void Shutdown() OVERRIDE {}
35 };
36
37 // This class holds the URL to use for resolving, and the expected result. 24 // This class holds the URL to use for resolving, and the expected result.
38 // We track the expected result in order to make sure the performance 25 // We track the expected result in order to make sure the performance
39 // test is actually resolving URLs properly, otherwise the perf numbers 26 // test is actually resolving URLs properly, otherwise the perf numbers
40 // are meaningless :-) 27 // are meaningless :-)
41 struct PacQuery { 28 struct PacQuery {
42 const char* query_url; 29 const char* query_url;
43 const char* expected_result; 30 const char* expected_result;
44 }; 31 };
45 32
46 // Entry listing which PAC scripts to load, and which URLs to try resolving. 33 // Entry listing which PAC scripts to load, and which URLs to try resolving.
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 runner.RunAllTests(); 187 runner.RunAllTests();
201 } 188 }
202 #elif defined(OS_MACOSX) 189 #elif defined(OS_MACOSX)
203 TEST(ProxyResolverPerfTest, ProxyResolverMac) { 190 TEST(ProxyResolverPerfTest, ProxyResolverMac) {
204 net::ProxyResolverMac resolver; 191 net::ProxyResolverMac resolver;
205 PacPerfSuiteRunner runner(&resolver, "ProxyResolverMac"); 192 PacPerfSuiteRunner runner(&resolver, "ProxyResolverMac");
206 runner.RunAllTests(); 193 runner.RunAllTests();
207 } 194 }
208 #endif 195 #endif
209 196
197 class MockJSBindings : public net::ProxyResolverV8::JSBindings {
198 public:
199 MockJSBindings() {}
200
201 virtual void Alert(const string16& message) OVERRIDE {
202 CHECK(false);
203 }
204
205 virtual bool ResolveDns(const std::string& host,
206 ResolveDnsOperation op,
207 std::string* output) OVERRIDE {
208 CHECK(false);
209 return false;
210 }
211
212 virtual void OnError(int line_number, const string16& message) OVERRIDE {
213 CHECK(false);
214 }
215 };
216
210 TEST(ProxyResolverPerfTest, ProxyResolverV8) { 217 TEST(ProxyResolverPerfTest, ProxyResolverV8) {
211 net::ProxyResolverJSBindings* js_bindings = 218 MockJSBindings js_bindings;
212 net::ProxyResolverJSBindings::CreateDefault( 219 net::ProxyResolverV8 resolver;
213 new MockSyncHostResolver, NULL, NULL); 220 resolver.set_js_bindings(&js_bindings);
214
215 net::ProxyResolverV8 resolver(js_bindings);
216 PacPerfSuiteRunner runner(&resolver, "ProxyResolverV8"); 221 PacPerfSuiteRunner runner(&resolver, "ProxyResolverV8");
217 runner.RunAllTests(); 222 runner.RunAllTests();
218 } 223 }
219 224
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698