64 lines
1.2 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the Do What The Fuck You Want To
  7. // Public License, Version 2, as published by Sam Hocevar. See
  8. // http://www.wtfpl.net/ for more details.
  9. //
  10. #include <lol/engine-internal.h>
  11. #include <cstdio>
  12. #include "loldebug.h"
  13. namespace lol
  14. {
  15. /*
  16. * DebugStats implementation class
  17. */
  18. class DebugStatsData
  19. {
  20. friend class DebugStats;
  21. private:
  22. FILE *fp;
  23. };
  24. /*
  25. * Public DebugStats class
  26. */
  27. DebugStats::DebugStats(char const *path)
  28. : data(new DebugStatsData())
  29. {
  30. data->fp = fopen(path, "w+");
  31. m_gamegroup = GAMEGROUP_AFTER;
  32. }
  33. void DebugStats::TickGame(float seconds)
  34. {
  35. Entity::TickGame(seconds);
  36. fprintf(data->fp, "%i %f %f %f %f\n",
  37. Ticker::GetFrameNum(),
  38. Profiler::GetAvg(Profiler::STAT_TICK_GAME),
  39. Profiler::GetAvg(Profiler::STAT_TICK_DRAW),
  40. Profiler::GetAvg(Profiler::STAT_TICK_BLIT),
  41. Profiler::GetAvg(Profiler::STAT_TICK_FRAME));
  42. }
  43. DebugStats::~DebugStats()
  44. {
  45. fclose(data->fp);
  46. delete data;
  47. }
  48. } /* namespace lol */