Optimizing Batch Operations
For batch applications—those that run a fixed amount of work—the choice of compiler boils
down to which gets the best optimization in the amount of time the application runs.
Table 4-2 shows an example of that.
Table 4-2. Time to execute batch applications
Number of stocks -client
0.142 seconds 0.176 seconds 0.165 seconds
0.211 seconds 0.348 seconds 0.226 seconds
0.454 seconds 0.674 seconds 0.472 seconds
2.556 seconds 2.158 seconds 1.910 seconds
23.78 seconds 14.03 seconds 13.56 seconds
Using the sample stock code discussed in Chapter 2 , the application here requests 1 year's
history (plus the average and standard deviation of that history) for between 1 and 10,000
For 1 to 100 stocks, the faster startup with the client compiler completes the job sooner, and
if the goal is to process only 100 stocks, the client compiler is the best choice. After that, the
performance advantage swings in favor of the server compiler (and particularly the server
compiler with tiered compilation). Even for a limited number of calculations, tiered compila-
tion is pretty close to the client compiler, making it a good candidate for all cases.
It is also interesting that tiered compilation is always slightly better than the standard server
compiler. In theory, once the program has run enough to compile all the hot spots, the server
compiler might be expected to achieve the best (or at least equal) performance. But in any
application, there will almost always be some small section of code that is infrequently ex-
ecuted. It is better to compile that code—even if the compilation is not the best that might be
achieved—than to execute that code in interpreted mode. And as is discussed later in this
chapter (see Compilation Thresholds ), the server compiler will likely never actually compile
all the code in an application, even if it runs forever.