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

Side by Side Diff: net/base/mime_sniffer_perftest.cc

Issue 1058003005: Mime sniffer: reduce table from 256 bytes to 4 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add unit tests for ContainsControlCodes() Created 5 years, 8 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
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698