2
0

Tracer.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright (C) 2009-2018, 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/Tracer.h>
  7. #include <anki/util/HighRezTimer.h>
  8. ANKI_TEST(Util, Tracer)
  9. {
  10. HeapAllocator<U8> alloc(allocAligned, nullptr);
  11. Tracer tracer;
  12. tracer.init(alloc);
  13. // 1st frame
  14. tracer.newFrame(0);
  15. ANKI_TEST_EXPECT_NO_ERR(tracer.flush("./0"));
  16. // 2nd frame
  17. // 2 same events
  18. tracer.newFrame(1);
  19. auto handle0 = tracer.beginEvent();
  20. HighRezTimer::sleep(0.5);
  21. tracer.endEvent("event", handle0);
  22. auto handle1 = tracer.beginEvent();
  23. HighRezTimer::sleep(0.5);
  24. tracer.endEvent("event", handle1);
  25. // 4rd frame
  26. // 2 different events & non zero counter
  27. tracer.newFrame(3);
  28. auto handle2 = tracer.beginEvent();
  29. HighRezTimer::sleep(0.5);
  30. tracer.endEvent("event", handle2);
  31. auto handle3 = tracer.beginEvent();
  32. HighRezTimer::sleep(0.5);
  33. tracer.endEvent("event2", handle3);
  34. tracer.increaseCounter("counter", 100);
  35. // 5th frame
  36. tracer.newFrame(4);
  37. tracer.increaseCounter("counter", 150);
  38. HighRezTimer::sleep(0.1);
  39. ANKI_TEST_EXPECT_NO_ERR(tracer.flush("./1"));
  40. }