MCPcopy Create free account
hub / github.com/cmu-db/benchbase / BenchmarkState

Class BenchmarkState

src/main/java/com/oltpbenchmark/BenchmarkState.java:26–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24import org.slf4j.LoggerFactory;
25
26public final class BenchmarkState {
27
28 private static final Logger LOG = LoggerFactory.getLogger(BenchmarkState.class);
29
30 private final long testStartNs;
31 private final CountDownLatch startBarrier;
32 private final AtomicInteger notDoneCount;
33 private volatile State state = State.WARMUP;
34
35 /**
36 * @param numThreads number of threads involved in the test: including the master thread.
37 */
38 public BenchmarkState(int numThreads) {
39 startBarrier = new CountDownLatch(numThreads);
40 notDoneCount = new AtomicInteger(numThreads);
41
42 testStartNs = System.nanoTime();
43 }
44
45 // Protected by this
46
47 public long getTestStartNs() {
48 return testStartNs;
49 }
50
51 public State getState() {
52 synchronized (this) {
53 return state;
54 }
55 }
56
57 /** Wait for all threads to call this. Returns once all the threads have entered. */
58 public void blockForStart() {
59
60 startBarrier.countDown();
61 try {
62 startBarrier.await();
63 } catch (InterruptedException e) {
64 throw new RuntimeException(e);
65 }
66 }
67
68 public void startMeasure() {
69 state = State.MEASURE;
70 }
71
72 public void startColdQuery() {
73 state = State.COLD_QUERY;
74 }
75
76 public void startHotQuery() {
77 state = State.MEASURE;
78 }
79
80 public void signalLatencyComplete() {
81 state = State.LATENCY_COMPLETE;
82 }
83

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected