Skip to content
 
 

Latest commit

 

History

38 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chronicle-Ticker

A time ticker as a light weight clock

Simple Tickers

Tickers which use System.currentTimeMillis() or nanoTime()
Ticker ticker = Ticker.millis();
// or
Ticker ticker = Ticker.nanos();

double timeInSec = ticker.count() / (double) ticker.countPerSecond();
Ticker for testing purposes
Ticker ticker = Ticker.forTesting()
                      .count(System.currentTimeMillis());
// or
Ticker ticker = Ticker.forTesting()
                      .count(System.currentTimeMillis() * 1000)
                      .countPerSecond(1_000_000)
                      .countFromEpoch(0);

double timeInSecs = ticker.count() / (double) ticker.countPerSecond();

High resolution ticker

Ticker which uses a high resolution time
Ticker ticker = Ticker.highResolution();

long start = ticker.count();
// do some work
long end = ticker.count();

double timeInSecs = (double) (end - start) / ticker.countPerSecond();
// or
long timeInMicros = (end - start) * 1_000 / ticker.countPerSecond();
// or
long timeInMillis = (end - start) * 1_000_000 / ticker.countPerSecond();

Performance

Table 1. Measured on a i7 - 7820X (3.6 GHz)

Ticker

Latency

Ticker.nanos().count()

14.8 ns

Ticker.highResolution().count()

6.8 ns

Releases

Packages

Contributors

Languages