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

Side by Side Diff: webrtc/modules/remote_bitrate_estimator/test/bwe_test.cc

Issue 1413053002: Change to use local Random object instead of global rand() in the RtcEventLog unit test. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Updated WebRTC unit tests to use the new functions in Random Created 5 years, 2 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 944
945 std::vector<int> BweTest::GetFileSizesBytes(int num_files) { 945 std::vector<int> BweTest::GetFileSizesBytes(int num_files) {
946 // File size chosen from uniform distribution between [100,1000] kB. 946 // File size chosen from uniform distribution between [100,1000] kB.
947 const int kMinKbytes = 100; 947 const int kMinKbytes = 100;
948 const int kMaxKbytes = 1000; 948 const int kMaxKbytes = 1000;
949 949
950 test::Random random(0x12345678); 950 test::Random random(0x12345678);
951 std::vector<int> tcp_file_sizes_bytes; 951 std::vector<int> tcp_file_sizes_bytes;
952 952
953 while (num_files-- > 0) { 953 while (num_files-- > 0) {
954 tcp_file_sizes_bytes.push_back(random.Rand(kMinKbytes, kMaxKbytes) * 1000); 954 tcp_file_sizes_bytes.push_back(random.Uniform(kMinKbytes, kMaxKbytes) *
955 1000);
955 } 956 }
956 957
957 return tcp_file_sizes_bytes; 958 return tcp_file_sizes_bytes;
958 } 959 }
959 960
960 std::vector<int64_t> BweTest::GetStartingTimesMs(int num_files) { 961 std::vector<int64_t> BweTest::GetStartingTimesMs(int num_files) {
961 // OFF state behaves as an exp. distribution with mean = 10 seconds. 962 // OFF state behaves as an exp. distribution with mean = 10 seconds.
962 const float kMeanMs = 10000.0f; 963 const float kMeanMs = 10000.0f;
963 test::Random random(0x12345678); 964 test::Random random(0x12345678);
964 965
965 std::vector<int64_t> tcp_starting_times_ms; 966 std::vector<int64_t> tcp_starting_times_ms;
966 967
967 // Two TCP Flows are initialized simultaneosly at t=0 seconds. 968 // Two TCP Flows are initialized simultaneosly at t=0 seconds.
968 for (int i = 0; i < 2; ++i, --num_files) { 969 for (int i = 0; i < 2; ++i, --num_files) {
969 tcp_starting_times_ms.push_back(0); 970 tcp_starting_times_ms.push_back(0);
970 } 971 }
971 972
972 // Other TCP Flows are initialized in an OFF state. 973 // Other TCP Flows are initialized in an OFF state.
973 while (num_files-- > 0) { 974 while (num_files-- > 0) {
974 tcp_starting_times_ms.push_back( 975 tcp_starting_times_ms.push_back(
975 static_cast<int64_t>(random.Exponential(1.0f / kMeanMs))); 976 static_cast<int64_t>(random.Exponential(1.0f / kMeanMs)));
976 } 977 }
977 978
978 return tcp_starting_times_ms; 979 return tcp_starting_times_ms;
979 } 980 }
980 981
981 } // namespace bwe 982 } // namespace bwe
982 } // namespace testing 983 } // namespace testing
983 } // namespace webrtc 984 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698