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

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

Issue 1378123003: Adding SSL ETS Tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ets
Patch Set: Rebase. Created 5 years, 1 month 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/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/test/perf_time_logger.h" 11 #include "base/test/perf_time_logger.h"
12 #include "net/base/net_errors.h" 12 #include "net/base/net_errors.h"
13 #include "net/dns/mock_host_resolver.h" 13 #include "net/dns/mock_host_resolver.h"
14 #include "net/proxy/proxy_info.h" 14 #include "net/proxy/proxy_info.h"
15 #include "net/proxy/proxy_resolver.h" 15 #include "net/proxy/proxy_resolver.h"
16 #include "net/proxy/proxy_resolver_factory.h" 16 #include "net/proxy/proxy_resolver_factory.h"
17 #include "net/proxy/proxy_resolver_v8.h" 17 #include "net/proxy/proxy_resolver_v8.h"
18 #include "net/test/spawned_test_server/spawned_test_server.h" 18 #include "net/test/embedded_test_server/embedded_test_server.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 20
21 #if defined(OS_WIN) 21 #if defined(OS_WIN)
22 #include "net/proxy/proxy_resolver_winhttp.h" 22 #include "net/proxy/proxy_resolver_winhttp.h"
23 #elif defined(OS_MACOSX) 23 #elif defined(OS_MACOSX)
24 #include "net/proxy/proxy_resolver_mac.h" 24 #include "net/proxy/proxy_resolver_mac.h"
25 #endif 25 #endif
26 26
27 namespace net { 27 namespace net {
28 28
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // The number of URLs to resolve when testing a PAC script. 83 // The number of URLs to resolve when testing a PAC script.
84 const int kNumIterations = 500; 84 const int kNumIterations = 500;
85 85
86 // Helper class to run through all the performance tests using the specified 86 // Helper class to run through all the performance tests using the specified
87 // proxy resolver implementation. 87 // proxy resolver implementation.
88 class PacPerfSuiteRunner { 88 class PacPerfSuiteRunner {
89 public: 89 public:
90 // |resolver_name| is the label used when logging the results. 90 // |resolver_name| is the label used when logging the results.
91 PacPerfSuiteRunner(ProxyResolverFactory* factory, 91 PacPerfSuiteRunner(ProxyResolverFactory* factory,
92 const std::string& resolver_name) 92 const std::string& resolver_name)
93 : factory_(factory), 93 : factory_(factory), resolver_name_(resolver_name) {
94 resolver_name_(resolver_name), 94 test_server_.ServeFilesFromSourceDirectory(
95 test_server_(SpawnedTestServer::TYPE_HTTP, 95 "net/data/proxy_resolver_perftest");
96 SpawnedTestServer::kLocalhost, 96 }
97 base::FilePath(FILE_PATH_LITERAL(
98 "net/data/proxy_resolver_perftest"))) {}
99 97
100 void RunAllTests() { 98 void RunAllTests() {
101 ASSERT_TRUE(test_server_.Start()); 99 ASSERT_TRUE(test_server_.Start());
102 for (size_t i = 0; i < arraysize(kPerfTests); ++i) { 100 for (size_t i = 0; i < arraysize(kPerfTests); ++i) {
103 const PacPerfTest& test_data = kPerfTests[i]; 101 const PacPerfTest& test_data = kPerfTests[i];
104 RunTest(test_data.pac_name, 102 RunTest(test_data.pac_name,
105 test_data.queries, 103 test_data.queries,
106 test_data.NumQueries()); 104 test_data.NumQueries());
107 } 105 }
108 } 106 }
109 107
110 private: 108 private:
111 void RunTest(const std::string& script_name, 109 void RunTest(const std::string& script_name,
112 const PacQuery* queries, 110 const PacQuery* queries,
113 int queries_len) { 111 int queries_len) {
114 scoped_ptr<ProxyResolver> resolver; 112 scoped_ptr<ProxyResolver> resolver;
115 if (!factory_->expects_pac_bytes()) { 113 if (!factory_->expects_pac_bytes()) {
116 GURL pac_url = 114 GURL pac_url = test_server_.GetURL(std::string("/") + script_name);
117 test_server_.GetURL(std::string("files/") + script_name);
118 int rv = factory_->CreateProxyResolver( 115 int rv = factory_->CreateProxyResolver(
119 ProxyResolverScriptData::FromURL(pac_url), &resolver, 116 ProxyResolverScriptData::FromURL(pac_url), &resolver,
120 CompletionCallback(), nullptr); 117 CompletionCallback(), nullptr);
121 EXPECT_EQ(OK, rv); 118 EXPECT_EQ(OK, rv);
122 } else { 119 } else {
123 resolver = LoadPacScriptAndCreateResolver(script_name); 120 resolver = LoadPacScriptAndCreateResolver(script_name);
124 } 121 }
125 ASSERT_TRUE(resolver); 122 ASSERT_TRUE(resolver);
126 123
127 // Do a query to warm things up. In the case of internal-fetch proxy 124 // Do a query to warm things up. In the case of internal-fetch proxy
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 scoped_ptr<ProxyResolver> resolver; 179 scoped_ptr<ProxyResolver> resolver;
183 int rv = factory_->CreateProxyResolver( 180 int rv = factory_->CreateProxyResolver(
184 ProxyResolverScriptData::FromUTF8(file_contents), &resolver, 181 ProxyResolverScriptData::FromUTF8(file_contents), &resolver,
185 CompletionCallback(), nullptr); 182 CompletionCallback(), nullptr);
186 EXPECT_EQ(OK, rv); 183 EXPECT_EQ(OK, rv);
187 return resolver; 184 return resolver;
188 } 185 }
189 186
190 ProxyResolverFactory* factory_; 187 ProxyResolverFactory* factory_;
191 std::string resolver_name_; 188 std::string resolver_name_;
192 SpawnedTestServer test_server_; 189 EmbeddedTestServer test_server_;
193 }; 190 };
194 191
195 #if defined(OS_WIN) 192 #if defined(OS_WIN)
196 TEST(ProxyResolverPerfTest, ProxyResolverWinHttp) { 193 TEST(ProxyResolverPerfTest, ProxyResolverWinHttp) {
197 ProxyResolverFactoryWinHttp factory; 194 ProxyResolverFactoryWinHttp factory;
198 PacPerfSuiteRunner runner(&factory, "ProxyResolverWinHttp"); 195 PacPerfSuiteRunner runner(&factory, "ProxyResolverWinHttp");
199 runner.RunAllTests(); 196 runner.RunAllTests();
200 } 197 }
201 #elif defined(OS_MACOSX) 198 #elif defined(OS_MACOSX)
202 TEST(ProxyResolverPerfTest, ProxyResolverMac) { 199 TEST(ProxyResolverPerfTest, ProxyResolverMac) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 TEST(ProxyResolverPerfTest, ProxyResolverV8) { 276 TEST(ProxyResolverPerfTest, ProxyResolverV8) {
280 base::MessageLoop message_loop; 277 base::MessageLoop message_loop;
281 ProxyResolverV8Factory factory; 278 ProxyResolverV8Factory factory;
282 PacPerfSuiteRunner runner(&factory, "ProxyResolverV8"); 279 PacPerfSuiteRunner runner(&factory, "ProxyResolverV8");
283 runner.RunAllTests(); 280 runner.RunAllTests();
284 } 281 }
285 282
286 } // namespace 283 } // namespace
287 284
288 } // namespace net 285 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/dhcp_proxy_script_adapter_fetcher_win_unittest.cc ('k') | net/proxy/proxy_script_fetcher_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698