mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-15 21:00:47 +00:00
Make timing based test more likely to pass
Summary: This assumed that the expect statement would run within 1us, whereas we only care it runs in less than the 100ms to check that it got reset. Closes https://github.com/caffe2/caffe2/pull/1606 Reviewed By: Yangqing Differential Revision: D6572951 Pulled By: pietern fbshipit-source-id: fd0c2854bc6459c8bf0e17fa75035eb0a4e522cd
This commit is contained in:
parent
28ea5ac069
commit
6552ea110f
1 changed files with 6 additions and 1 deletions
|
|
@ -26,21 +26,26 @@ namespace {
|
|||
|
||||
TEST(TimerTest, Test) {
|
||||
Timer timer;
|
||||
|
||||
// A timer auto-starts when it is constructed.
|
||||
std::this_thread::sleep_for(std::chrono::microseconds(1));
|
||||
EXPECT_GT(timer.NanoSeconds(), 0);
|
||||
|
||||
// Sleep for a while, and get the time.
|
||||
timer.Start();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
float ns = timer.NanoSeconds();
|
||||
float us = timer.MicroSeconds();
|
||||
float ms = timer.MilliSeconds();
|
||||
|
||||
// Time should be at least accurate +- 10%.
|
||||
EXPECT_NEAR(ns, 100000000, 10000000);
|
||||
EXPECT_NEAR(us, 100000, 10000);
|
||||
EXPECT_NEAR(ms, 100, 10);
|
||||
|
||||
// Test restarting the clock.
|
||||
timer.Start();
|
||||
EXPECT_LT(timer.NanoSeconds(), 1000);
|
||||
EXPECT_LT(timer.MicroSeconds(), 1000);
|
||||
}
|
||||
|
||||
TEST(TimerTest, TestLatency) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue