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

Unified Diff: remoting/test/fake_socket_factory.cc

Issue 2354263007: Minor fixes for protocol perf tests (Closed)
Patch Set: no rand Created 4 years, 3 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 | remoting/test/protocol_perftest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/test/fake_socket_factory.cc
diff --git a/remoting/test/fake_socket_factory.cc b/remoting/test/fake_socket_factory.cc
index 39a9e862855a0dce3d809bb1c6925a9cf8070317..e9f72844e0702d7e6125c4202bb7344e71db4d09 100644
--- a/remoting/test/fake_socket_factory.cc
+++ b/remoting/test/fake_socket_factory.cc
@@ -7,16 +7,15 @@
#include "remoting/test/fake_socket_factory.h"
-#include <math.h>
-#include <stddef.h>
-
+#include <cmath>
+#include <cstddef>
+#include <cstdlib>
#include <string>
#include "base/bind.h"
#include "base/callback.h"
#include "base/location.h"
#include "base/macros.h"
-#include "base/rand_util.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
@@ -33,12 +32,16 @@ namespace {
const int kPortRangeStart = 1024;
const int kPortRangeEnd = 65535;
+double RandDouble() {
+ return static_cast<double>(std::rand()) / RAND_MAX;
+}
+
double GetNormalRandom(double average, double stddev) {
// Based on Box-Muller transform, see
// http://en.wikipedia.org/wiki/Box_Muller_transform .
return average +
- stddev * sqrt(-2.0 * log(1.0 - base::RandDouble())) *
- cos(base::RandDouble() * 2.0 * M_PI);
+ stddev * sqrt(-2.0 * log(1.0 - RandDouble())) *
+ cos(RandDouble() * 2.0 * M_PI);
}
class FakeUdpSocket : public rtc::AsyncPacketSocket {
@@ -328,7 +331,7 @@ void FakePacketSocketFactory::DoReceivePacket() {
DCHECK(task_runner_->BelongsToCurrentThread());
PendingPacket packet;
- if (pending_packets_.size() > 1 && base::RandDouble() < out_of_order_rate_) {
+ if (pending_packets_.size() > 1 && RandDouble() < out_of_order_rate_) {
std::list<PendingPacket>::iterator it = pending_packets_.begin();
++it;
packet = *it;
« no previous file with comments | « no previous file | remoting/test/protocol_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698