source: trunk/src/debugstats.cpp @ 203

Last change on this file since 203 was 203, checked in by sam, 10 years ago

Add a stats logger entity.

  • Property svn:keywords set to Id
File size: 994 bytes
Line 
1//
2// Deus Hax (working title)
3// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
4//
5
6#if defined HAVE_CONFIG_H
7#   include "config.h"
8#endif
9
10#include <cstdio>
11
12#include "core.h"
13#include "debugstats.h"
14
15/*
16 * DebugStats implementation class
17 */
18
19class DebugStatsData
20{
21    friend class DebugStats;
22
23private:
24    FILE *fp;
25};
26
27/*
28 * Public DebugStats class
29 */
30
31DebugStats::DebugStats(char const *path)
32{
33    data = new DebugStatsData();
34    data->fp = fopen(path, "w+");
35}
36
37Entity::Group DebugStats::GetGroup()
38{
39    return GROUP_AFTER;
40}
41
42void DebugStats::TickGame(float deltams)
43{
44    Entity::TickGame(deltams);
45
46    fprintf(data->fp, "%i %f %f %f %f\n",
47            Ticker::GetFrameNum(),
48            Profiler::GetAvg(Profiler::STAT_TICK_GAME),
49            Profiler::GetAvg(Profiler::STAT_TICK_DRAW),
50            Profiler::GetAvg(Profiler::STAT_TICK_BLIT),
51            Profiler::GetAvg(Profiler::STAT_TICK_FRAME));
52}
53
54DebugStats::~DebugStats()
55{
56    fclose(data->fp);
57    delete data;
58}
59
Note: See TracBrowser for help on using the repository browser.