I'm trying to test and measure the performance of my javacc parser. Note that the parser is supposed to read some message and marshal it to xml format. I already did some unit testing but I need to check how fast it is. what is the recommended way/ tools to do it?
1 Answers
Here is what I would do. Generate a small file into a StringBuffer. Create a string from the string buffer, a string reader from the string, and a parser from the reader. Note the CPU time. Parse. Note the CPU time again. Subtract. Now repeat for a larger file and an even larger one and so on. I'd restart the JVM process for each repetition so that garbage collection is less likely to happen. The time for small files will likely be strongly affected by cache size. As files get larger the parse time per byte will probably approach a limit. That limit will reflect the time per byte ignoring cache.
See http://nadeausoftware.com/articles/2008/03/java_tip_how_get_cpu_and_user_time_benchmarking for information on getting the CPU time.
Of course a number of factors will try to mess up your results. For example garbage collection. See Measuring time spent on GC in JVM.

- 1
- 1

- 15,366
- 6
- 31
- 45