OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 using base::TimeTicks; | 395 using base::TimeTicks; |
396 TimeTicks start = TimeTicks::HighResNow(); | 396 TimeTicks start = TimeTicks::HighResNow(); |
397 for (int x = 0; x < iterations_; ++x) { | 397 for (int x = 0; x < iterations_; ++x) { |
398 MaskWebSocketFramePayload(masking_key, x % size, &scratch.front(), | 398 MaskWebSocketFramePayload(masking_key, x % size, &scratch.front(), |
399 scratch.size()); | 399 scratch.size()); |
400 } | 400 } |
401 double total_time_ms = | 401 double total_time_ms = |
402 1000 * (TimeTicks::HighResNow() - start).InMillisecondsF() / | 402 1000 * (TimeTicks::HighResNow() - start).InMillisecondsF() / |
403 iterations_; | 403 iterations_; |
404 LOG(INFO) << "Payload size " << size | 404 LOG(INFO) << "Payload size " << size |
405 << StringPrintf(" took %.03f microseconds per iteration", | 405 << base::StringPrintf(" took %.03f microseconds per iteration", |
406 total_time_ms); | 406 total_time_ms); |
407 } | 407 } |
408 | 408 |
409 private: | 409 private: |
410 int iterations_; | 410 int iterations_; |
411 | 411 |
412 DISALLOW_COPY_AND_ASSIGN(WebSocketFrameTestMaskBenchmark); | 412 DISALLOW_COPY_AND_ASSIGN(WebSocketFrameTestMaskBenchmark); |
413 }; | 413 }; |
414 | 414 |
415 TEST_F(WebSocketFrameTestMaskBenchmark, BenchmarkMaskShortPayload) { | 415 TEST_F(WebSocketFrameTestMaskBenchmark, BenchmarkMaskShortPayload) { |
416 static const char kShortPayload[] = "Short Payload"; | 416 static const char kShortPayload[] = "Short Payload"; |
417 Benchmark(kShortPayload, arraysize(kShortPayload)); | 417 Benchmark(kShortPayload, arraysize(kShortPayload)); |
418 } | 418 } |
419 | 419 |
420 TEST_F(WebSocketFrameTestMaskBenchmark, BenchmarkMaskLongPayload) { | 420 TEST_F(WebSocketFrameTestMaskBenchmark, BenchmarkMaskLongPayload) { |
421 scoped_array<char> payload(new char[kLongPayloadSize]); | 421 scoped_array<char> payload(new char[kLongPayloadSize]); |
422 std::fill(payload.get(), payload.get() + kLongPayloadSize, 'a'); | 422 std::fill(payload.get(), payload.get() + kLongPayloadSize, 'a'); |
423 Benchmark(payload.get(), kLongPayloadSize); | 423 Benchmark(payload.get(), kLongPayloadSize); |
424 } | 424 } |
425 | 425 |
426 } // namespace net | 426 } // namespace net |
OLD | NEW |