Chromium Code Reviews| Index: base/rand_util_unittest.cc |
| diff --git a/base/rand_util_unittest.cc b/base/rand_util_unittest.cc |
| index e0e85ecaa91a6d38e63e57397e80a42848a3cdc5..81281dba9336f44aa1d30fb5958000745d681385 100644 |
| --- a/base/rand_util_unittest.cc |
| +++ b/base/rand_util_unittest.cc |
| @@ -7,6 +7,9 @@ |
| #include <algorithm> |
| #include <limits> |
| +#include "base/logging.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/time/time.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| namespace { |
| @@ -120,3 +123,19 @@ TEST(RandUtilTest, RandUint64ProducesBothValuesOfAllBits) { |
| FAIL() << "Didn't achieve all bit values in maximum number of tries."; |
| } |
| + |
| +TEST(RandUtilTest, DISABLED_RandBytesPerf) { |
|
wtc
2014/01/22 22:29:09
We should document why this test is DISABLED.
DaleCurtis
2014/01/22 22:54:14
Done.
|
| + // Benchmark the performance of |kTestIterations| of RandBytes() using a |
| + // buffer size of |kTestBufferSize|. |
| + const int kTestIterations = 10; |
| + const size_t kTestBufferSize = 1 * 1024 * 1024; |
| + |
| + scoped_ptr<uint8[]> buffer(new uint8[kTestBufferSize]); |
| + const base::TimeTicks now = base::TimeTicks::HighResNow(); |
| + for (int i = 0; i < kTestIterations; ++i) |
| + base::RandBytes(buffer.get(), kTestBufferSize); |
| + const base::TimeTicks end = base::TimeTicks::HighResNow(); |
| + |
| + LOG(INFO) << "RandBytes(" << kTestBufferSize << ") took: " |
| + << (end - now).InMicroseconds() << "µs"; |
| +} |