summaryrefslogtreecommitdiffstats
path: root/src/Utility.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-08-12 17:09:16 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-08-12 17:09:16 +0200
commit45de7d0537d2caec7d0a7ede48e2b72301bc9da9 (patch)
treeaf17dd093da09dc77a3a07a3d4835a1b5e5b85f6 /src/Utility.cpp
parent2017-08-07 (diff)
downloadAltCraft-45de7d0537d2caec7d0a7ede48e2b72301bc9da9.tar
AltCraft-45de7d0537d2caec7d0a7ede48e2b72301bc9da9.tar.gz
AltCraft-45de7d0537d2caec7d0a7ede48e2b72301bc9da9.tar.bz2
AltCraft-45de7d0537d2caec7d0a7ede48e2b72301bc9da9.tar.lz
AltCraft-45de7d0537d2caec7d0a7ede48e2b72301bc9da9.tar.xz
AltCraft-45de7d0537d2caec7d0a7ede48e2b72301bc9da9.tar.zst
AltCraft-45de7d0537d2caec7d0a7ede48e2b72301bc9da9.zip
Diffstat (limited to '')
-rw-r--r--src/Utility.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/Utility.cpp b/src/Utility.cpp
index b4e1d99..ebb6981 100644
--- a/src/Utility.cpp
+++ b/src/Utility.cpp
@@ -55,27 +55,29 @@ unsigned long long LoopExecutionTimeController::GetIterations() {
void LoopExecutionTimeController::Update() {
iterations++;
- auto timeToSleep = delayLength - GetDelta();
- if (timeToSleep.count()>0)
- std::this_thread::sleep_for(timeToSleep);
- previousUpdate = clock::now();
+ auto timeToSleep = delayLength - GetDelta();
+ if (timeToSleep.count() > 0)
+ std::this_thread::sleep_for(timeToSleep);
+ previousPreviousUpdate = previousUpdate;
+ previousUpdate = clock::now();
}
double LoopExecutionTimeController::GetDeltaMs() {
- auto now = clock::now();
- return duration(now-previousUpdate).count();
+ std::chrono::duration<double, std::milli> delta = GetDelta();
+ return delta.count();
}
LoopExecutionTimeController::duration LoopExecutionTimeController::GetDelta() {
auto now = clock::now();
- //std::cerr<<duration(now-previousUpdate).count()<<std::endl;
return duration(now-previousUpdate);
}
-double LoopExecutionTimeController::GetDeltaS()
-{
- auto now = clock::now();
- return std::chrono::duration<double, std::ratio<1, 1>>(now - previousUpdate).count();
+double LoopExecutionTimeController::GetDeltaS() {
+ std::chrono::duration<double, std::ratio<1,1>> delta = GetDelta();
+ return delta.count();
}
-
+double LoopExecutionTimeController::GetRealDeltaS()
+{
+ return std::chrono::duration<double,std::ratio<1,1>>(previousUpdate - previousPreviousUpdate).count();
+}