HighRezTimer.cpp 552 B

12345678910111213141516171819202122232425262728
  1. // Copyright (C) 2009-2016, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #include "tests/framework/Framework.h"
  6. #include "anki/util/HighRezTimer.h"
  7. #include <unistd.h>
  8. ANKI_TEST(Util, Test)
  9. {
  10. HighRezTimer t;
  11. t.start();
  12. sleep(2);
  13. ANKI_TEST_EXPECT_NEAR(t.getElapsedTime(), 2.0, 0.2);
  14. sleep(1);
  15. ANKI_TEST_EXPECT_NEAR(t.getElapsedTime(), 3.0, 0.2);
  16. sleep(1);
  17. t.stop();
  18. sleep(1);
  19. ANKI_TEST_EXPECT_NEAR(t.getElapsedTime(), 4.0, 0.2);
  20. }