Java Reference
In-Depth Information
CPU Profiling
It would be nice to have a straightforward checklist of things to check when you're profiling applications.
But it just isn't that easy. Profiling an application can, at times, feel more like an art than a science. This
section walks through how to obtain data related to the performance of your applications and their
utilization of the CPU.
When you look at how a CPU is performing within your application, you typically use the measure
of time to determine the hot spots (the areas that aren't performing to your expectations). What areas is
the CPU working in the most? For example, if you have an infinite loop somewhere in your code, the
CPU will spend a large amount of time there after it's triggered. However, if everything is running fine,
you can expect to see either no bottlenecks or at bottlenecks that you would expect (I/O is typically the
bottleneck of most modern systems).
To view the CPU profiling functionality at work, let's use the statement job that you completed in
the last chapter. This job consists of six steps and interacts with the Internet, files, and a database. Figure
11-6 shows from a high level what the job does as it's currently configured.
Import Customer and
Transaction Data
Retrieve Stock
Prices
Import Stock
Prices
Calculate Pricing
Tiers
Calculate
Transaction Fees
Generate Monthly
Statements
Figure 11-6. Statement job
To execute the job, you use the command java -jar statement-job-1.0.0-SNAPSHOT.jar
jobs/statementJob.xml statementJob -next . After you've launched the job, it appears in the VisualVM
menu on the left under Local. To connect to it, all you need to do is double-click it.
Now that you've connected to the running statement job, you can begin to look at how things
operate within it. Let's first look at the Monitor tab to see how busy the CPU is in the first place. After
running the statement job with a customer transaction file containing 100 customers and more than
20,000 transactions, you can see that the CPU utilization for this job is minimal. Figure 11-7 shows the
charts from the Monitor tab after a run of the job.
 
Search WWH ::




Custom Search