[ Team LiB ] |
8.2 When to Use JUnitPerf8.2.1 ProblemYou want to track down potential performance and scalability problems but are unsure of the tools you need. 8.2.2 SolutionUse a commercial profiling tool, such as JProbe or OptimizeIt, to manually inspect code and identify application bottlenecks. Use JUnitPerf to ensure that new features and refactoring do not slow down code that used to be fast enough. 8.2.3 DiscussionJUnitPerf is a tool for continuous performance testing. The goal of a performance test is to ensure that the code executes fast enough, even under varying load conditions. Let's take a look at a typical scenario. You just completed a custom search algorithm, complete with a suite of JUnit tests. Next, the code is run through a profiling tool to look for any potential bottlenecks. If any performance issues are found, a new JUnit test is written to isolate the code (if one does not already exist). For example, the profiling tool reports that the search took ten seconds, but requirements dictate that it execute in less than three. The new JUnit test is wrapped around a JUnitPerf TimedTest to expose the performance bug. The timed test should fail; otherwise, there is no performance issue with the code you have isolated. Next, refactor the code that is causing the performance problem until the timed test passes.
Here are the typical steps for writing a JUnitPerf test:
8.2.4 See AlsoRecipe 8.3 shows how to create a JUnitPerf TimedTest. Recipe 8.7 shows how to use Ant to execute JUnitPerf tests. |
[ Team LiB ] |