OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/rand_util.h" | 5 #include "base/rand_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 // Benchmark test for RandBytes(). Disabled since it's intentionally slow and | 127 // Benchmark test for RandBytes(). Disabled since it's intentionally slow and |
128 // does not test anything that isn't already tested by the existing RandBytes() | 128 // does not test anything that isn't already tested by the existing RandBytes() |
129 // tests. | 129 // tests. |
130 TEST(RandUtilTest, DISABLED_RandBytesPerf) { | 130 TEST(RandUtilTest, DISABLED_RandBytesPerf) { |
131 // Benchmark the performance of |kTestIterations| of RandBytes() using a | 131 // Benchmark the performance of |kTestIterations| of RandBytes() using a |
132 // buffer size of |kTestBufferSize|. | 132 // buffer size of |kTestBufferSize|. |
133 const int kTestIterations = 10; | 133 const int kTestIterations = 10; |
134 const size_t kTestBufferSize = 1 * 1024 * 1024; | 134 const size_t kTestBufferSize = 1 * 1024 * 1024; |
135 | 135 |
136 scoped_ptr<uint8[]> buffer(new uint8[kTestBufferSize]); | 136 scoped_ptr<uint8[]> buffer(new uint8[kTestBufferSize]); |
137 const base::TimeTicks now = base::TimeTicks::HighResNow(); | 137 const base::TimeTicks now = base::TimeTicks::Now(); |
138 for (int i = 0; i < kTestIterations; ++i) | 138 for (int i = 0; i < kTestIterations; ++i) |
139 base::RandBytes(buffer.get(), kTestBufferSize); | 139 base::RandBytes(buffer.get(), kTestBufferSize); |
140 const base::TimeTicks end = base::TimeTicks::HighResNow(); | 140 const base::TimeTicks end = base::TimeTicks::Now(); |
141 | 141 |
142 LOG(INFO) << "RandBytes(" << kTestBufferSize << ") took: " | 142 LOG(INFO) << "RandBytes(" << kTestBufferSize << ") took: " |
143 << (end - now).InMicroseconds() << "µs"; | 143 << (end - now).InMicroseconds() << "µs"; |
144 } | 144 } |
OLD | NEW |