Skip to content

Commit

Permalink
C++: de-flake profiler test
Browse files Browse the repository at this point in the history
There's no upper limit on the SleepMeasurably
call's sleep duration, therefore on rare occasions
a single SleepMeasurably call might take longer
than two separate, consecutive SleepMeasurably
calls.

For that reason, this patch changes the test to
only compare sleep durations where the clocks
measuring the durations were measuring the *same*
sleep calls, and not the same *number of* sleep
calls.

Change-Id: I8510e8ac3b202424237655968e3a5448527719e3

Closes #6215.

Change-Id: I8510e8ac3b202424237655968e3a5448527719e3
PiperOrigin-RevId: 214268374
laszlocsomor authored and Copybara-Service committed Sep 24, 2018
1 parent c82d1c0 commit 258222c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/test/cpp/util/profiler_test.cc
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ TEST(ProfilerTest, TestScopedTaskMeasuresElapsedTime) {
SleepMeasurably();
SleepMeasurably();
}
ASSERT_GT(scope2.GetDuration().micros_, scope1.GetDuration().micros_);
ASSERT_GT(scope_both.GetDuration().micros_, scope1.GetDuration().micros_);
ASSERT_GT(scope_both.GetDuration().micros_, scope2.GetDuration().micros_);
ASSERT_EQ(scope1.GetCalls(), 1u);
ASSERT_EQ(scope2.GetCalls(), 1u);

0 comments on commit 258222c

Please sign in to comment.