dev.pellet.server.metrics.PelletTimer.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pellet-server Show documentation
Show all versions of pellet-server Show documentation
An opinionated Kotlin web framework, with best-practices built-in
package dev.pellet.server.metrics
import java.time.Duration
import java.util.concurrent.atomic.AtomicLong
class PelletTimer : PelletTiming {
private val mark = AtomicLong(System.nanoTime())
override fun reset() {
val now = System.nanoTime()
mark.set(now)
}
override fun markAndReset(): Duration {
val now = System.nanoTime()
val previousMark = mark.get()
val difference = now - previousMark
mark.set(now)
return Duration.ofNanos(difference)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy