Index: test/cctest/test-heap-profiler.cc |
diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc |
index e720d92109ca13d23d08f42cde1edf79cf98fc9e..37a207a2fc999f5bd40ca5e5eb2a6166b026bd44 100644 |
--- a/test/cctest/test-heap-profiler.cc |
+++ b/test/cctest/test-heap-profiler.cc |
@@ -2929,7 +2929,7 @@ TEST(SamplingHeapProfiler) { |
CHECK(profile == nullptr); |
} |
- // Sampling at a higher rate should give us more sampled objects. |
+ // Sampling at a higher rate should give us similar numbers of objects. |
{ |
heap_profiler->StartSamplingHeapProfiler(32 * 1024); |
CompileRun(script_source); |
@@ -2949,10 +2949,16 @@ TEST(SamplingHeapProfiler) { |
count_32kb += allocation.count; |
} |
- // We should have roughly 16x as many sampled allocations. However, |
- // alignment and boundaries might tweak the numbers slightly. We use a |
- // slightly weaker test to account for this. |
- CHECK_GT(count_32kb, 8 * count_512kb); |
+ // We should have similar unsampled counts of allocations. Though |
+ // we will sample different numbers of objects at different rates, |
+ // the unsampling process should produce similar final estimates |
+ // at the true number of allocations. However, the process to |
+ // determine these unsampled counts is probabilisitic so we need to |
+ // account for error. |
+ double max_count = std::max(count_32kb, count_512kb); |
+ double min_count = std::min(count_32kb, count_512kb); |
+ double percent_difference = (max_count - min_count) / min_count; |
+ CHECK_LT(percent_difference, 0.15); |
heap_profiler->StopSamplingHeapProfiler(); |
} |