Java Reference
In-Depth Information
for(int i = 0; i < 1000000; i++){
new BigInteger(String.valueOf(i)).isProbablePrime(0);
}
if(atq.getTransactionCount() <= 1000) {
atq.setTier(PricingTier.I);
} else if(atq.getTransactionCount() > 1000 &&
atq.getTransactionCount() <= 100000) {
atq.setTier(PricingTier.II);
} else if(atq.getTransactionCount() > 100000 &&
atq.getTransactionCount() <= 1000000) {
atq.setTier(PricingTier.III);
} else {
atq.setTier(PricingTier.IV);
}
return atq;
}
}
Obviously the loop you added to calculate all the prime numbers between 0 and 1 million as shown
in Listing 11-1 is unlikely to end up in your code. But it's exactly the type of accidental looping that could
cause a catastrophic impact on the performance of a batch job over the course of processing millions of
transactions. Figure 11-8 shows the impact this small loop makes on CPU utilization, according to
VirtualVM.
Figure 11-8. CPU utilization for the updated statement job
Search WWH ::




Custom Search