Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "net/base/mime_sniffer.h" | |
| 6 | |
| 7 #include <vector> | |
| 8 | |
| 9 #include "base/test/perf_time_logger.h" | |
| 10 #include "testing/gtest/include/gtest/gtest.h" | |
| 11 | |
| 12 namespace net { | |
| 13 namespace { | |
| 14 | |
| 15 TEST(MimeSnifferTest, FastPathPerfTest) { | |
|
asanka
2015/04/29 23:17:44
Not very keen on this type of perftest that measur
Adam Rice
2015/05/07 16:52:50
I don't expect micro-benchmarks to be representati
asanka
2015/05/12 19:20:41
Interesting. Thanks for running the tests. I also
| |
| 16 std::vector<char> plaintext(1 << 28, ' '); | |
| 17 base::PerfTimeLogger timer("MimeSnifferFastPathPerf_256MB"); | |
| 18 ContainsControlCodes(&plaintext[0], plaintext.size()); | |
| 19 } | |
| 20 | |
| 21 TEST(MimeSnifferTest, SlowPathPerfTest) { | |
| 22 const size_t target_size = 1 << 28; | |
| 23 // The control characters force the code to do an array lookup. The "a" is | |
| 24 // there to make branch prediction harder. | |
| 25 std::string plaintext = "\ta\r\n"; | |
| 26 plaintext.reserve(target_size); | |
| 27 while (plaintext.size() < target_size) | |
| 28 plaintext += plaintext; | |
| 29 base::PerfTimeLogger timer("MimeSnifferSlowPathPerf_256MB"); | |
| 30 ContainsControlCodes(&plaintext[0], plaintext.size()); | |
| 31 } | |
| 32 | |
| 33 } // namespace net | |
| 34 } // namespace | |
| OLD | NEW |