Tracer.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright (C) 2009-2023, 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/Core/CoreTracer.h>
  8. #include <AnKi/Util/HighRezTimer.h>
  9. #if ANKI_ENABLE_TRACE
  10. ANKI_TEST(Util, Tracer)
  11. {
  12. HeapMemoryPool alloc(allocAligned, nullptr);
  13. CoreTracer tracer;
  14. ANKI_TEST_EXPECT_NO_ERR(tracer.init(&alloc, "./"));
  15. Tracer::getSingleton().setEnabled(true);
  16. // 1st frame
  17. tracer.flushFrame(0);
  18. // 2nd frame
  19. // 2 events
  20. {
  21. ANKI_TRACE_SCOPED_EVENT(EVENT);
  22. HighRezTimer::sleep(0.5);
  23. }
  24. {
  25. ANKI_TRACE_SCOPED_EVENT(EVENT);
  26. HighRezTimer::sleep(0.25);
  27. }
  28. tracer.flushFrame(1);
  29. // 4rd frame
  30. // 2 different events & non zero counter
  31. {
  32. ANKI_TRACE_SCOPED_EVENT(EVENT);
  33. HighRezTimer::sleep(0.5);
  34. }
  35. {
  36. ANKI_TRACE_SCOPED_EVENT(EVENT2);
  37. HighRezTimer::sleep(0.25);
  38. }
  39. ANKI_TRACE_INC_COUNTER(COUNTER, 100);
  40. tracer.flushFrame(3);
  41. // 5th frame
  42. ANKI_TRACE_INC_COUNTER(COUNTER, 150);
  43. tracer.flushFrame(4);
  44. }
  45. #endif