Sped up logic core execution by 1000%
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Thu, 26 Sep 2019 12:42:09 +0000 (14:42 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Thu, 26 Sep 2019 12:42:09 +0000 (14:42 +0200)
plugins/net.mograsim.logic.core/src/net/mograsim/logic/core/timeline/PauseableTimeFunction.java

index 4a99310..ed95ec0 100644 (file)
@@ -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)