Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "Headers/ProfileTimer.h"
#include "Headers/ApplicationTimer.h"
#include "Headers/Console.h"

namespace Divide {

ProfileTimer::~ProfileTimer()
{
    ApplicationTimer::getInstance().removeTimer(this);
}

ProfileTimer::ProfileTimer()
{
    _init = false;
    _paused = false;
    _timer = 0.0;
#if defined(_DEBUG) || defined(_PROFILE)
    _timerAverage = 0.0;
    _timerCounter = 0;
#endif
}

void ProfileTimer::reset() {
#if defined(_DEBUG) || defined(_PROFILE)
    _timerAverage = 0.0;
    _timerCounter = 0;
#endif
}

void ProfileTimer::start() {
#if defined(_DEBUG) || defined(_PROFILE)
    _timer = getUsToMs(ApplicationTimer::getInstance().getElapsedTime(true));
#endif
}

void ProfileTimer::stop() {
#if defined(_DEBUG) || defined(_PROFILE)
    if (_paused) {
        reset();
        return;
    }

    _timer = getUsToMs(ApplicationTimer::getInstance().getElapsedTime(true)) - _timer;
    _timerAverage = _timerAverage + _timer;
    _timerCounter++;
#endif
}

void ProfileTimer::create(const stringImpl& name){
    if (_init) {
        return;
    }

    _name = name;
    _init = true;
    // should never be called twice for the same object
    ApplicationTimer::getInstance().addTimer(this);
}

void ProfileTimer::print() const {
#if defined(_DEBUG) || defined(_PROFILE)
    if (!_paused) {
        PRINT_FN("[ %s ] : [ %5.3f ms]", _name.c_str(), _timerAverage / _timerCounter);
    }
#endif
}

};//namespace Divide

Commits for Divide-Framework/trunk/Source Code/Core/ProfileTimer.cpp

Diff revisions: vs.
Revision Author Commited Message
337 IonutCava picture IonutCava Wed 17 Dec, 2014 17:25:16 +0000

[Ionut]
- Replaced all tabs with 4 spaces (some spacing may be off now. no way to check all the files.)
- Moved implementation details for ParamHandler, BoundingBox, BoundingSphere and ProfileTimer to proper .inl and .cpp files. (more to follow)
- Update all forward declared enums with the required storage type (as requested by the C++11 standard)