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

Unified Diff: media/base/seekable_buffer_unittest.cc

Issue 139303022: Replace use of base::RandXXX() with rand() to improve runtime of SeekableBufferTest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/seekable_buffer_unittest.cc
diff --git a/media/base/seekable_buffer_unittest.cc b/media/base/seekable_buffer_unittest.cc
index 9b02ef211c639f151acfbfdcb6481dc1ec99fad8..898ea45e8c7ef32d54370e225e4e8ce950ca7cff 100644
--- a/media/base/seekable_buffer_unittest.cc
+++ b/media/base/seekable_buffer_unittest.cc
@@ -2,9 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <cstdlib>
+
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
-#include "base/rand_util.h"
#include "base/time/time.h"
#include "media/base/data_buffer.h"
#include "media/base/seekable_buffer.h"
@@ -23,13 +24,19 @@ class SeekableBufferTest : public testing::Test {
static const int kWriteSize = 512;
virtual void SetUp() {
+ // Note: We use srand() and rand() rather than base::RandXXX() to improve
+ // unit test performance. We don't need good random numbers, just
+ // something that generates "mixed data."
+ const unsigned int kKnownSeed = 0x98765432;
+ srand(kKnownSeed);
+
// Create random test data samples.
for (int i = 0; i < kDataSize; i++)
- data_[i] = static_cast<char>(base::RandInt(0, 255));
+ data_[i] = static_cast<char>(rand());
DaleCurtis 2014/01/17 23:28:21 You might try base::RandBytes()... after this CL t
}
int GetRandomInt(int maximum) {
- return base::RandInt(0, maximum);
+ return rand() % (maximum + 1);
}
SeekableBuffer buffer_;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698