diff options
author | Sven Gothel <[email protected]> | 2023-03-06 22:16:58 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-03-06 22:16:58 +0100 |
commit | 0836295b52aaad1dce10a31a13cb544802d7de03 (patch) | |
tree | 22c3993b50a2783d8ac87084936f24661ae0ff1c /src/java/com/jogamp/common/util | |
parent | a26445909b3677a8c2de669992a13de2053fa821 (diff) |
Fix Clock for performance counter: Add currentTimeNanos() since module startup, retrievable via getMonotonicStartupTime(). (performance)
Settings two long fields in getMonotonicTime() and creating Instant and using Duration
for high-frequency counter is too expensive.
currentTimeNanos() subtracts the startup time from the current monotonic time and returns the
resulting duration in nanoseconds, which lasts for 292 years since module startup.
This satisfies performance counter requirements.
Diffstat (limited to 'src/java/com/jogamp/common/util')
-rw-r--r-- | src/java/com/jogamp/common/util/PerfCounterCtrl.java | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/java/com/jogamp/common/util/PerfCounterCtrl.java b/src/java/com/jogamp/common/util/PerfCounterCtrl.java index 486c248..30290f8 100644 --- a/src/java/com/jogamp/common/util/PerfCounterCtrl.java +++ b/src/java/com/jogamp/common/util/PerfCounterCtrl.java @@ -26,9 +26,15 @@ package com.jogamp.common.util; import java.io.PrintStream; -import java.time.Duration; +import com.jogamp.common.os.Clock; -/** Simple performance counter controller. */ +/** + * Simple performance counter controller. + * <p> + * Implementation is expected to utilize nanosecond counter since module start, + * e.g. {@link Clock#currentTimeNanos()}. + * </p> + */ public interface PerfCounterCtrl { /** Enable or disable performance counter. */ void enable(final boolean enable); @@ -36,8 +42,8 @@ public interface PerfCounterCtrl { /** Clear performance counter. */ void clear(); - /** Return the total duration, covering all sub-counter. */ - Duration getTotalDuration(); + /** Return the total duration in nanoseconds, covering all sub-counter. */ + long getTotalDuration(); /** Print performance counter. */ void print(final PrintStream out); |