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

Side by Side Diff: net/websockets/websocket_frame_perftest.cc

Issue 826973002: replace COMPILE_ASSERT with static_assert in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: apply fixups Created 5 years, 11 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 | « net/websockets/websocket_frame.cc ('k') | net/websockets/websocket_frame_test.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/websockets/websocket_frame.h" 5 #include "net/websockets/websocket_frame.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/test/perf_time_logger.h" 11 #include "base/test/perf_time_logger.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace net { 14 namespace net {
15 15
16 namespace { 16 namespace {
17 17
18 const int kIterations = 100000; 18 const int kIterations = 100000;
19 const int kLongPayloadSize = 1 << 16; 19 const int kLongPayloadSize = 1 << 16;
20 const char kMaskingKey[] = "\xFE\xED\xBE\xEF"; 20 const char kMaskingKey[] = "\xFE\xED\xBE\xEF";
21 21
22 COMPILE_ASSERT(arraysize(kMaskingKey) == 22 static_assert(arraysize(kMaskingKey) ==
23 WebSocketFrameHeader::kMaskingKeyLength + 1, 23 WebSocketFrameHeader::kMaskingKeyLength + 1,
24 incorrect_masking_key_size); 24 "incorrect masking key size");
25 25
26 class WebSocketFrameTestMaskBenchmark : public ::testing::Test { 26 class WebSocketFrameTestMaskBenchmark : public ::testing::Test {
27 protected: 27 protected:
28 void Benchmark(const char* const name, 28 void Benchmark(const char* const name,
29 const char* const payload, 29 const char* const payload,
30 size_t size) { 30 size_t size) {
31 std::vector<char> scratch(payload, payload + size); 31 std::vector<char> scratch(payload, payload + size);
32 WebSocketMaskingKey masking_key; 32 WebSocketMaskingKey masking_key;
33 std::copy(kMaskingKey, 33 std::copy(kMaskingKey,
34 kMaskingKey + WebSocketFrameHeader::kMaskingKeyLength, 34 kMaskingKey + WebSocketFrameHeader::kMaskingKeyLength,
(...skipping 14 matching lines...) Expand all
49 } 49 }
50 50
51 TEST_F(WebSocketFrameTestMaskBenchmark, BenchmarkMaskLongPayload) { 51 TEST_F(WebSocketFrameTestMaskBenchmark, BenchmarkMaskLongPayload) {
52 std::vector<char> payload(kLongPayloadSize, 'a'); 52 std::vector<char> payload(kLongPayloadSize, 'a');
53 Benchmark("Frame_mask_long_payload", &payload.front(), payload.size()); 53 Benchmark("Frame_mask_long_payload", &payload.front(), payload.size());
54 } 54 }
55 55
56 } // namespace 56 } // namespace
57 57
58 } // namespace net 58 } // namespace net
OLDNEW
« no previous file with comments | « net/websockets/websocket_frame.cc ('k') | net/websockets/websocket_frame_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698