Deflake CpuTimeTest.TwoThreads
The test sometimes failed because thread creation on some platforms on internal tests may take too much work. Now checks are less strict. Bug: none Change-Id: Ibd3df02bda26b0c5e804360a909c61afa760b3bc Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/165960 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30267}
This commit is contained in:
parent
d61338fa6e
commit
7787ebcd3f
@ -26,7 +26,7 @@
|
||||
|
||||
namespace {
|
||||
const int kAllowedErrorMillisecs = 30;
|
||||
const int kProcessingTimeMillisecs = 300;
|
||||
const int kProcessingTimeMillisecs = 500;
|
||||
const int kWorkingThreads = 2;
|
||||
|
||||
// Consumes approximately kProcessingTimeMillisecs of CPU time in single thread.
|
||||
@ -77,10 +77,11 @@ TEST(CpuTimeTest, MAYBE_TEST(TwoThreads)) {
|
||||
GetProcessCpuTimeNanos() - process_start_time_nanos;
|
||||
int64_t thread_duration_nanos =
|
||||
GetThreadCpuTimeNanos() - thread_start_time_nanos;
|
||||
// This thread did almost nothing.
|
||||
// This thread did almost nothing. Definetly less work than kProcessingTime.
|
||||
// Therefore GetThreadCpuTime is not a wall clock.
|
||||
EXPECT_LE(thread_duration_nanos,
|
||||
kAllowedErrorMillisecs * kNumNanosecsPerMillisec);
|
||||
(kProcessingTimeMillisecs - kAllowedErrorMillisecs) *
|
||||
kNumNanosecsPerMillisec);
|
||||
// Total process time is at least twice working threads' CPU time.
|
||||
// Therefore process and thread times are correctly related.
|
||||
EXPECT_GE(process_duration_nanos,
|
||||
@ -97,7 +98,8 @@ TEST(CpuTimeTest, MAYBE_TEST(Sleeping)) {
|
||||
// Sleeping should not introduce any additional CPU time.
|
||||
// Therefore GetProcessCpuTime is not a wall clock.
|
||||
EXPECT_LE(process_duration_nanos,
|
||||
kWorkingThreads * kAllowedErrorMillisecs * kNumNanosecsPerMillisec);
|
||||
(kProcessingTimeMillisecs - kAllowedErrorMillisecs) *
|
||||
kNumNanosecsPerMillisec);
|
||||
}
|
||||
|
||||
} // namespace rtc
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user