From 083389c8016a79ae6d65d5227bd6a66de1732092 Mon Sep 17 00:00:00 2001 From: Daniel Kirschten Date: Thu, 26 Sep 2019 14:42:09 +0200 Subject: [PATCH] Sped up logic core execution by 1000% --- .../mograsim/logic/core/timeline/PauseableTimeFunction.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/net.mograsim.logic.core/src/net/mograsim/logic/core/timeline/PauseableTimeFunction.java b/plugins/net.mograsim.logic.core/src/net/mograsim/logic/core/timeline/PauseableTimeFunction.java index 4a99310c..ed95ec03 100644 --- a/plugins/net.mograsim.logic.core/src/net/mograsim/logic/core/timeline/PauseableTimeFunction.java +++ b/plugins/net.mograsim.logic.core/src/net/mograsim/logic/core/timeline/PauseableTimeFunction.java @@ -22,7 +22,7 @@ public class PauseableTimeFunction implements LongSupplier if (paused) { paused = false; - unpausedSysTime = System.currentTimeMillis(); + unpausedSysTime = System.nanoTime() / 1000; } } @@ -30,12 +30,12 @@ public class PauseableTimeFunction implements LongSupplier public long getAsLong() { return (long) (paused ? lastPausedInternalTime - : lastPausedInternalTime + (System.currentTimeMillis() - unpausedSysTime) * speedFactor); + : lastPausedInternalTime + (System.nanoTime() / 1000 - unpausedSysTime) * speedFactor); } public long simulTimeDeltaToRealTimeMillis(long simulTime) { - return paused ? -1 : (long) (simulTime / speedFactor); + return paused ? -1 : (long) (simulTime / speedFactor / 1000); } public void setSpeedFactor(double factor) -- 2.17.1