From 6545ab42048dfda5f6cb72ce272a331078cd200e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 7 Mar 2023 01:16:30 +0100 Subject: Clock: Use Clock.currentNanos() instead of System.nanoTime() --- src/java/com/jogamp/common/os/Platform.java | 4 ++-- src/java/com/jogamp/common/util/ReflectionUtil.java | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/java/com/jogamp/common') diff --git a/src/java/com/jogamp/common/os/Platform.java b/src/java/com/jogamp/common/os/Platform.java index 9c65596..ffea42c 100644 --- a/src/java/com/jogamp/common/os/Platform.java +++ b/src/java/com/jogamp/common/os/Platform.java @@ -540,11 +540,11 @@ public class Platform extends PlatformPropsImpl { } private static long getCurrentSleepJitterImpl(final long nsDuration, final int splitInLoops) { final long nsPeriod = nsDuration / splitInLoops; - final long t0_ns = System.nanoTime(); + final long t0_ns = Clock.currentNanos(); for(int i=splitInLoops; i>0; i--) { try { TimeUnit.NANOSECONDS.sleep(nsPeriod); } catch (final InterruptedException e) { } } - return ( ( System.nanoTime() - t0_ns ) - nsDuration ) / splitInLoops; + return ( ( Clock.currentNanos() - t0_ns ) - nsDuration ) / splitInLoops; } } diff --git a/src/java/com/jogamp/common/util/ReflectionUtil.java b/src/java/com/jogamp/common/util/ReflectionUtil.java index 0d76827..27ca983 100644 --- a/src/java/com/jogamp/common/util/ReflectionUtil.java +++ b/src/java/com/jogamp/common/util/ReflectionUtil.java @@ -51,6 +51,7 @@ import jogamp.common.Debug; import com.jogamp.common.ExceptionUtils; import com.jogamp.common.JogampRuntimeException; +import com.jogamp.common.os.Clock; public final class ReflectionUtil { @@ -125,9 +126,9 @@ public final class ReflectionUtil { private static Class getClassImpl(final String clazzName, final boolean initializeClazz, final ClassLoader cl) throws ClassNotFoundException { if(DEBUG_STATS_FORNAME) { - final long t0 = System.nanoTime(); + final long t0 = Clock.currentNanos(); final Class res = Class.forName(clazzName, initializeClazz, cl); - final long t1 = System.nanoTime(); + final long t1 = Clock.currentNanos(); final long nanoCosts = t1 - t0; synchronized(forNameLock) { forNameCount++; -- cgit v1.2.3