add clock-based temporal binding functions

This commit is contained in:
Jonathan Shook 2021-11-04 21:57:41 -05:00
parent 6a5e9616b9
commit fea9cce437
2 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,17 @@
package io.nosqlbench.virtdata.library.basics.shared.from_long.to_time_types;
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
import java.util.function.LongUnaryOperator;
/**
* Provide the millisecond epoch time as given by <pre>{@code System.currentTimeMillis()}</pre>
* CAUTION: This does not produce deterministic test data.
*/
@ThreadSafeMapper
public class CurrentEpochMillis implements LongUnaryOperator {
@Override
public long applyAsLong(long operand) {
return System.currentTimeMillis();
}
}

View File

@ -0,0 +1,17 @@
package io.nosqlbench.virtdata.library.basics.shared.from_long.to_time_types;
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
import java.util.function.LongUnaryOperator;
/**
* Provide the elapsed nano time since the process started.
* CAUTION: This does not produce deterministic test data.
*/
@ThreadSafeMapper
public class ElapsedNanoTime implements LongUnaryOperator {
@Override
public long applyAsLong(long operand) {
return System.nanoTime();
}
}