| 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/proxy/proxy_resolver_v8.h" | 6 #include "net/proxy/proxy_resolver_v8.h" |
| 7 #include "net/url_request/url_request_unittest.h" | 7 #include "net/url_request/url_request_unittest.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
| 11 #include "net/proxy/proxy_resolver_winhttp.h" | 11 #include "net/proxy/proxy_resolver_winhttp.h" |
| 12 #elif defined(OS_MACOSX) | 12 #elif defined(OS_MACOSX) |
| 13 #include "net/proxy/proxy_resolver_mac.h" | 13 #include "net/proxy/proxy_resolver_mac.h" |
| 14 #endif | 14 #endif |
| 15 | 15 |
| 16 // This class holds the URL to use for resolving, and the expected result. | 16 // This class holds the URL to use for resolving, and the expected result. |
| 17 // We track the expected result in order to make sure the performance | 17 // We track the expected result in order to make sure the performance |
| 18 // test is actually resolving URLs properly, otherwise the perf numbers | 18 // test is actually resolving URLs properly, otherwise the perf numbers |
| 19 // are meaningless :-) | 19 // are meaningless :-) |
| 20 struct PacQuery { | 20 struct PacQuery { |
| 21 const char* query_url; | 21 const char* query_url; |
| 22 const char* expected_result; | 22 const char* expected_result; |
| 23 }; | 23 }; |
| 24 | 24 |
| 25 // Entry listing which PAC scripts to load, and which URLs to try resolving. | 25 // Entry listing which PAC scripts to load, and which URLs to try resolving. |
| 26 // |queries| should be terminated by {NULL, NULL}. A sentinel is used | 26 // |queries| should be terminated by {NULL, NULL}. A sentinel is used |
| 27 // rather than a length, to simplify using initializer lists. | 27 // rather than a length, to simplify using initializer lists. |
| 28 struct PacPerfTest { | 28 struct PacPerfTest { |
| 29 const char* pac_name; | 29 const char* pac_name; |
| 30 PacQuery queries[100]; | 30 PacQuery queries[100]; |
| 31 | 31 |
| 32 // Returns the actual number of entries in |queries| (assumes NULL sentinel). | 32 // Returns the actual number of entries in |queries| (assumes NULL sentinel). |
| 33 int NumQueries() const; | 33 int NumQueries() const; |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 // List of performance tests. | 36 // List of performance tests. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 50 {"http://www.foobarbaz.com/x/y/z", "DIRECT"}, | 50 {"http://www.foobarbaz.com/x/y/z", "DIRECT"}, |
| 51 {"http://www.testurl1.com/index.html", "DIRECT"}, | 51 {"http://www.testurl1.com/index.html", "DIRECT"}, |
| 52 {"http://www.testurl2.com", "DIRECT"}, | 52 {"http://www.testurl2.com", "DIRECT"}, |
| 53 {"https://www.sample/pirate/arrrrrr", "DIRECT"}, | 53 {"https://www.sample/pirate/arrrrrr", "DIRECT"}, |
| 54 {NULL, NULL} | 54 {NULL, NULL} |
| 55 }, | 55 }, |
| 56 }, | 56 }, |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 int PacPerfTest::NumQueries() const { | 59 int PacPerfTest::NumQueries() const { |
| 60 for (int i = 0; i < arraysize(queries); ++i) { | 60 for (size_t i = 0; i < arraysize(queries); ++i) { |
| 61 if (queries[i].query_url == NULL) | 61 if (queries[i].query_url == NULL) |
| 62 return i; | 62 return i; |
| 63 } | 63 } |
| 64 NOTREACHED(); // Bad definition. | 64 NOTREACHED(); // Bad definition. |
| 65 return 0; | 65 return 0; |
| 66 } | 66 } |
| 67 | 67 |
| 68 // The number of URLs to resolve when testing a PAC script. | 68 // The number of URLs to resolve when testing a PAC script. |
| 69 const int kNumIterations = 500; | 69 const int kNumIterations = 500; |
| 70 | 70 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 PacPerfSuiteRunner runner(&resolver, "ProxyResolverMac"); | 182 PacPerfSuiteRunner runner(&resolver, "ProxyResolverMac"); |
| 183 runner.RunAllTests(); | 183 runner.RunAllTests(); |
| 184 } | 184 } |
| 185 #endif | 185 #endif |
| 186 | 186 |
| 187 TEST(ProxyResolverPerfTest, ProxyResolverV8) { | 187 TEST(ProxyResolverPerfTest, ProxyResolverV8) { |
| 188 net::ProxyResolverV8 resolver; | 188 net::ProxyResolverV8 resolver; |
| 189 PacPerfSuiteRunner runner(&resolver, "ProxyResolverV8"); | 189 PacPerfSuiteRunner runner(&resolver, "ProxyResolverV8"); |
| 190 runner.RunAllTests(); | 190 runner.RunAllTests(); |
| 191 } | 191 } |
| OLD | NEW |