All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dev.pellet.server.metrics.PelletTimer.kt Maven / Gradle / Ivy

There is a newer version: 0.0.16
Show newest version
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