Java Reference
In-Depth Information
cessor stepping level, number of CPUs, or memory size) to require dynamic configuration, it
is equally common that reasonable choices for these values work well across a wide range of
systems.
12.2.1. Extending PutTakeTest to Add Timing
The primary extension we have to make to PutTakeTest is to measure the time taken for
a run. Rather than attempting to measure the time for a single operation, we get a more ac-
curate measure by timing the entire run and dividing by the number of operations to get a
per-operation time. We are already using a CyclicBarrier to start and stop the worker
threads, so we can extend this by using a barrier action that measures the start and end time,
as shown in Listing 12.11 .
We can modify the initialization of the barrier to use this barrier action by using the construct-
or for CyclicBarrier that accepts a barrier action:
Search WWH ::




Custom Search