| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <cmath> | 5 #include <cmath> |
| 6 #include <limits> | 6 #include <limits> |
| 7 #include <numeric> | 7 #include <numeric> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/guid.h" | 10 #include "base/guid.h" |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 | 328 |
| 329 ++count; | 329 ++count; |
| 330 } | 330 } |
| 331 | 331 |
| 332 ASSERT_LT(count, kMaxAttempts) << "Expected average was " << | 332 ASSERT_LT(count, kMaxAttempts) << "Expected average was " << |
| 333 kExpectedAverage << ", average ended at " << cumulative_average << | 333 kExpectedAverage << ", average ended at " << cumulative_average << |
| 334 ", for trial " << kTestTrialNames[i]; | 334 ", for trial " << kTestTrialNames[i]; |
| 335 } | 335 } |
| 336 } | 336 } |
| 337 | 337 |
| 338 TEST_F(EntropyProviderTest, Overlap) { |
| 339 const std::string kTrial1Name = "UMA-Uniformity-Trial-5-Percent"; |
| 340 const int kTrial1GroupCount = 20; |
| 341 std::vector<uint16> trial_1_mapping(kMaxLowEntropySize); |
| 342 internal::PermuteMappingUsingTrialName(kTrial1Name, &trial_1_mapping); |
| 343 |
| 344 const std::string kTrial2Name = "UMA-Uniformity-Trial-10-Percent"; |
| 345 const int kTrial2GroupCount = 10; |
| 346 std::vector<uint16> trial_2_mapping(kMaxLowEntropySize); |
| 347 internal::PermuteMappingUsingTrialName(kTrial2Name, &trial_2_mapping); |
| 348 |
| 349 const double kEntropyDivisor = static_cast<double>(kMaxLowEntropySize); |
| 350 |
| 351 std::vector<std::vector<int> > counts; // trial1,trial2 |
| 352 counts.resize(kTrial1GroupCount); |
| 353 for (size_t i = 0; i < kTrial1GroupCount; ++i) |
| 354 counts[i].resize(kTrial2GroupCount); |
| 355 |
| 356 for (size_t i = 0; i < kMaxLowEntropySize; ++i) { |
| 357 uint16 trial_1_mapped_entropy = trial_1_mapping[i]; |
| 358 double trial_1_random_value = trial_1_mapped_entropy / kEntropyDivisor; |
| 359 int trial_1_group = trial_1_random_value * kTrial1GroupCount; |
| 360 |
| 361 uint16 trial_2_mapped_entropy = trial_2_mapping[i]; |
| 362 double trial_2_random_value = trial_2_mapped_entropy / kEntropyDivisor; |
| 363 int trial_2_group = trial_2_random_value * kTrial2GroupCount; |
| 364 |
| 365 counts[trial_1_group][trial_2_group]++; |
| 366 } |
| 367 |
| 368 for (size_t i = 0; i < counts.size(); ++i) { |
| 369 for (size_t j = 0; j < counts[i].size(); j++) { |
| 370 printf("%d\t", counts[i][j]); |
| 371 } |
| 372 puts(""); |
| 373 } |
| 374 } |
| 375 |
| 338 } // namespace metrics | 376 } // namespace metrics |
| OLD | NEW |