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
#include "Headers/ApplicationTimer.h"
#include "Headers/ProfileTimer.h"

#include "Core/Headers/Console.h"
#include "Core/Math/Headers/MathHelper.h"
#include "Utility/Headers/Localization.h"

namespace Divide {
namespace Time {

ApplicationTimer::ApplicationTimer()
    : _targetFrameRate(Config::TARGET_FRAME_RATE),
      _speedfactor(1.0f),
      _elapsedTimeUs(0UL),
      _lastBenchmarkTimeStamp(0UL)
{
    _startupTicks = getCurrentTicksInternal();
    _frameDelay = _startupTicks;
    _frameRateHandler.init(_targetFrameRate, 0);
}

ApplicationTimer::~ApplicationTimer()
{
}

void ApplicationTimer::update() {
    TimeValue currentTicks = getCurrentTicksInternal();
    _elapsedTimeUs = getElapsedTimeInternal(currentTicks);

    USec duration = std::chrono::duration_cast<USec>(currentTicks - _frameDelay);
    _speedfactor = Time::MicrosecondsToSeconds<F32>(static_cast<U64>(duration.count() * _targetFrameRate));

    _frameDelay = currentTicks;

    U64 elapsedTime = getElapsedTimeInternal(currentTicks);
    _frameRateHandler.tick(elapsedTime);
    
    if (Config::Profile::BENCHMARK_PERFORMANCE) {

        if (elapsedTime - _lastBenchmarkTimeStamp >
            Time::SecondsToMicroseconds(Config::Profile::BENCHMARK_FREQUENCY))
        {
            _lastBenchmarkTimeStamp = elapsedTime;
            _lastBenchmarkReport = 
                Util::StringFormat(Locale::get(_ID("FRAMERATE_FPS_OUTPUT")),
                                   _frameRateHandler.averageFrameRate(),
                                   _frameRateHandler.maxFrameRate(),
                                   _frameRateHandler.minFrameRate(),
                                   1000.0f / _frameRateHandler.averageFrameRate());
        }
    }
}

};  // namespace Time
};  // namespace Divide

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

Diff revisions: vs.
Revision Author Commited Message
693 IonutCava picture IonutCava Thu 28 Apr, 2016 16:19:35 +0000

[IonutCava]
- Cleanup Time and Profiling code