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

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

Issue 1457023002: Rewrote the PRNG using an xorshift* algorithm and moved the files from test/ to base/. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase Created 5 years 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 930 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 // Following functions are used for randomizing TCP file size and 941 // Following functions are used for randomizing TCP file size and
942 // starting time, used on 5.7 RunMultipleShortTcpFairness. 942 // starting time, used on 5.7 RunMultipleShortTcpFairness.
943 // They are pseudo-random generators, creating always the same 943 // They are pseudo-random generators, creating always the same
944 // value sequence for a given Random seed. 944 // value sequence for a given Random seed.
945 945
946 std::vector<int> BweTest::GetFileSizesBytes(int num_files) { 946 std::vector<int> BweTest::GetFileSizesBytes(int num_files) {
947 // File size chosen from uniform distribution between [100,1000] kB. 947 // File size chosen from uniform distribution between [100,1000] kB.
948 const int kMinKbytes = 100; 948 const int kMinKbytes = 100;
949 const int kMaxKbytes = 1000; 949 const int kMaxKbytes = 1000;
950 950
951 test::Random random(0x12345678); 951 Random random(0x12345678);
952 std::vector<int> tcp_file_sizes_bytes; 952 std::vector<int> tcp_file_sizes_bytes;
953 953
954 while (num_files-- > 0) { 954 while (num_files-- > 0) {
955 tcp_file_sizes_bytes.push_back(random.Rand(kMinKbytes, kMaxKbytes) * 1000); 955 tcp_file_sizes_bytes.push_back(random.Rand(kMinKbytes, kMaxKbytes) * 1000);
956 } 956 }
957 957
958 return tcp_file_sizes_bytes; 958 return tcp_file_sizes_bytes;
959 } 959 }
960 960
961 std::vector<int64_t> BweTest::GetStartingTimesMs(int num_files) { 961 std::vector<int64_t> BweTest::GetStartingTimesMs(int num_files) {
962 // OFF state behaves as an exp. distribution with mean = 10 seconds. 962 // OFF state behaves as an exp. distribution with mean = 10 seconds.
963 const float kMeanMs = 10000.0f; 963 const float kMeanMs = 10000.0f;
964 test::Random random(0x12345678); 964 Random random(0x12345678);
965 965
966 std::vector<int64_t> tcp_starting_times_ms; 966 std::vector<int64_t> tcp_starting_times_ms;
967 967
968 // Two TCP Flows are initialized simultaneosly at t=0 seconds. 968 // Two TCP Flows are initialized simultaneosly at t=0 seconds.
969 for (int i = 0; i < 2; ++i, --num_files) { 969 for (int i = 0; i < 2; ++i, --num_files) {
970 tcp_starting_times_ms.push_back(0); 970 tcp_starting_times_ms.push_back(0);
971 } 971 }
972 972
973 // Other TCP Flows are initialized in an OFF state. 973 // Other TCP Flows are initialized in an OFF state.
974 while (num_files-- > 0) { 974 while (num_files-- > 0) {
975 tcp_starting_times_ms.push_back( 975 tcp_starting_times_ms.push_back(
976 static_cast<int64_t>(random.Exponential(1.0f / kMeanMs))); 976 static_cast<int64_t>(random.Exponential(1.0f / kMeanMs)));
977 } 977 }
978 978
979 return tcp_starting_times_ms; 979 return tcp_starting_times_ms;
980 } 980 }
981 981
982 } // namespace bwe 982 } // namespace bwe
983 } // namespace testing 983 } // namespace testing
984 } // namespace webrtc 984 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698