You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

62 lines
1.2 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright: (c) 2010-2011 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://sam.zoy.org/projects/COPYING.WTFPL for more details.
  9. //
  10. #if defined HAVE_CONFIG_H
  11. # include "config.h"
  12. #endif
  13. #include <cstdio>
  14. #include "core.h"
  15. #include "debugstats.h"
  16. /*
  17. * DebugStats implementation class
  18. */
  19. class DebugStatsData
  20. {
  21. friend class DebugStats;
  22. private:
  23. FILE *fp;
  24. };
  25. /*
  26. * Public DebugStats class
  27. */
  28. DebugStats::DebugStats(char const *path)
  29. {
  30. data = new DebugStatsData();
  31. data->fp = fopen(path, "w+");
  32. gamegroup = GAMEGROUP_AFTER;
  33. }
  34. void DebugStats::TickGame(float deltams)
  35. {
  36. Entity::TickGame(deltams);
  37. fprintf(data->fp, "%i %f %f %f %f\n",
  38. Ticker::GetFrameNum(),
  39. Profiler::GetAvg(Profiler::STAT_TICK_GAME),
  40. Profiler::GetAvg(Profiler::STAT_TICK_DRAW),
  41. Profiler::GetAvg(Profiler::STAT_TICK_BLIT),
  42. Profiler::GetAvg(Profiler::STAT_TICK_FRAME));
  43. }
  44. DebugStats::~DebugStats()
  45. {
  46. fclose(data->fp);
  47. delete data;
  48. }