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

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

Issue 1404953002: Move PRNG from BWE test framework to webrtc/test. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 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 929 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 // Following functions are used for randomizing TCP file size and 940 // Following functions are used for randomizing TCP file size and
941 // starting time, used on 5.7 RunMultipleShortTcpFairness. 941 // starting time, used on 5.7 RunMultipleShortTcpFairness.
942 // They are pseudo-random generators, creating always the same 942 // They are pseudo-random generators, creating always the same
943 // value sequence for a given Random seed. 943 // value sequence for a given Random seed.
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 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.Rand(kMinKbytes, kMaxKbytes) * 1000);
955 } 955 }
956 956
957 return tcp_file_sizes_bytes; 957 return tcp_file_sizes_bytes;
958 } 958 }
959 959
960 std::vector<int64_t> BweTest::GetStartingTimesMs(int num_files) { 960 std::vector<int64_t> BweTest::GetStartingTimesMs(int num_files) {
961 // OFF state behaves as an exp. distribution with mean = 10 seconds. 961 // OFF state behaves as an exp. distribution with mean = 10 seconds.
962 const float kMeanMs = 10000.0f; 962 const float kMeanMs = 10000.0f;
963 Random random(0x12345678); 963 test::Random random(0x12345678);
964 964
965 std::vector<int64_t> tcp_starting_times_ms; 965 std::vector<int64_t> tcp_starting_times_ms;
966 966
967 // Two TCP Flows are initialized simultaneosly at t=0 seconds. 967 // Two TCP Flows are initialized simultaneosly at t=0 seconds.
968 for (int i = 0; i < 2; ++i, --num_files) { 968 for (int i = 0; i < 2; ++i, --num_files) {
969 tcp_starting_times_ms.push_back(0); 969 tcp_starting_times_ms.push_back(0);
970 } 970 }
971 971
972 // Other TCP Flows are initialized in an OFF state. 972 // Other TCP Flows are initialized in an OFF state.
973 while (num_files-- > 0) { 973 while (num_files-- > 0) {
974 tcp_starting_times_ms.push_back( 974 tcp_starting_times_ms.push_back(
975 static_cast<int64_t>(random.Exponential(1.0f / kMeanMs))); 975 static_cast<int64_t>(random.Exponential(1.0f / kMeanMs)));
976 } 976 }
977 977
978 return tcp_starting_times_ms; 978 return tcp_starting_times_ms;
979 } 979 }
980 980
981 } // namespace bwe 981 } // namespace bwe
982 } // namespace testing 982 } // namespace testing
983 } // namespace webrtc 983 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698