Java Reference
In-Depth Information
Listing 12.11. Barrier-based Timer.
The modified test method using the barrier-based timer is shown in Listing 12.12 .
We can learn several things from running TimedPutTakeTest . One is the throughput of
the producer-consumer handoff operation for various combinations of parameters; another is
how the bounded buffer scales with different numbers of threads; a third is how we might
select the bound size. Answering these questions requires running the test for various com-
binations of parameters, so we'll need amain test driver, shown in Listing 12.13 .
Figure 12.1 shows some sample results on a 4-way machine, using buffer capacities of 1, 10,
100, and 1000. We see immediately that a buffer size of one causes very poor throughput; this
is because each thread can make only a tiny bit of progress before blocking and waiting for
another thread. Increasing buffer size to ten helps dramatically, but increases past ten offer
diminishing returns.
Search WWH ::




Custom Search