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

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

Issue 1858423002: Fix C4334 (32-bit shift converted to 64-bit) warnings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing obsolete comment and pointless '1' Created 4 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
« no previous file with comments | « media/filters/vp8_parser.cc ('k') | net/spdy/hpack/hpack_huffman_table.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 "net/base/mime_sniffer.h" 5 #include "net/base/mime_sniffer.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bits.h" 9 #include "base/bits.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } 78 }
79 79
80 TEST(MimeSnifferTest, PlainTextPerfTest) { 80 TEST(MimeSnifferTest, PlainTextPerfTest) {
81 // Android systems have a relatively small CPU cache (512KB to 2MB). 81 // Android systems have a relatively small CPU cache (512KB to 2MB).
82 // It is better if the test data fits in cache so that we are not just 82 // It is better if the test data fits in cache so that we are not just
83 // testing bus bandwidth. 83 // testing bus bandwidth.
84 const size_t kTargetSize = 1 << 18; // 256KB 84 const size_t kTargetSize = 1 << 18; // 256KB
85 const size_t kWarmupIterations = 16; 85 const size_t kWarmupIterations = 16;
86 const size_t kMeasuredIterations = 1 << 15; 86 const size_t kMeasuredIterations = 1 << 15;
87 std::string plaintext = kRepresentativePlainText; 87 std::string plaintext = kRepresentativePlainText;
88 // The purpose of the static_cast<size_t>() here is to prevent MSVC from 88 size_t expected_size = plaintext.size() << base::bits::Log2Ceiling(
89 // complaining about an implicit promotion to 64 bits when compiling 64-bit. 89 kTargetSize / plaintext.size());
90 size_t expected_size =
91 plaintext.size() *
92 static_cast<size_t>(
93 1u << base::bits::Log2Ceiling(kTargetSize / plaintext.size()));
94 plaintext.reserve(expected_size); 90 plaintext.reserve(expected_size);
95 while (plaintext.size() < kTargetSize) 91 while (plaintext.size() < kTargetSize)
96 plaintext += plaintext; 92 plaintext += plaintext;
97 DCHECK_EQ(expected_size, plaintext.size()); 93 DCHECK_EQ(expected_size, plaintext.size());
98 RunLooksLikeBinary(plaintext, kWarmupIterations); 94 RunLooksLikeBinary(plaintext, kWarmupIterations);
99 base::ElapsedTimer elapsed_timer; 95 base::ElapsedTimer elapsed_timer;
100 RunLooksLikeBinary(plaintext, kMeasuredIterations); 96 RunLooksLikeBinary(plaintext, kMeasuredIterations);
101 LOG(INFO) << (elapsed_timer.Elapsed().InMicroseconds() * 1000 * 1024 / 97 LOG(INFO) << (elapsed_timer.Elapsed().InMicroseconds() * 1000 * 1024 /
102 (static_cast<int64_t>(plaintext.size()) * kMeasuredIterations)) 98 (static_cast<int64_t>(plaintext.size()) * kMeasuredIterations))
103 << "ns per KB"; 99 << "ns per KB";
104 } 100 }
105 101
106 } // namespace net 102 } // namespace net
107 } // namespace 103 } // namespace
OLDNEW
« no previous file with comments | « media/filters/vp8_parser.cc ('k') | net/spdy/hpack/hpack_huffman_table.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698