source: trunk/src/debug/stats.cpp @ 1310

Last change on this file since 1310 was 1310, checked in by sam, 8 years ago

core: tick methods now use seconds, like any sane system.

  • Property svn:keywords set to Id
File size: 1.3 KB
Line 
1//
2// Lol Engine
3//
4// Copyright: (c) 2010-2012 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
11#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include <cstdio>
16
17#include "core.h"
18#include "loldebug.h"
19
20using namespace std;
21
22namespace lol
23{
24
25/*
26 * DebugStats implementation class
27 */
28
29class DebugStatsData
30{
31    friend class DebugStats;
32
33private:
34    FILE *fp;
35};
36
37/*
38 * Public DebugStats class
39 */
40
41DebugStats::DebugStats(char const *path)
42  : data(new DebugStatsData())
43{
44    data->fp = fopen(path, "w+");
45
46    m_gamegroup = GAMEGROUP_AFTER;
47}
48
49void DebugStats::TickGame(float seconds)
50{
51    Entity::TickGame(seconds);
52
53    fprintf(data->fp, "%i %f %f %f %f\n",
54            Ticker::GetFrameNum(),
55            Profiler::GetAvg(Profiler::STAT_TICK_GAME),
56            Profiler::GetAvg(Profiler::STAT_TICK_DRAW),
57            Profiler::GetAvg(Profiler::STAT_TICK_BLIT),
58            Profiler::GetAvg(Profiler::STAT_TICK_FRAME));
59}
60
61DebugStats::~DebugStats()
62{
63    fclose(data->fp);
64    delete data;
65}
66
67} /* namespace lol */
68
Note: See TracBrowser for help on using the repository browser.