<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<font face="Tahoma">Hi<br>
<br>
Performance testing on the Java VM is tricky. <br>
To avoid getting caught out by cache-hot/cache-cold and JIT vs.
not-JIT things, it's preferrable to do something like this in
PerfTest#timeRun(Runnnable)<br>
<br>
// warm up the caches and get the JIT going<br>
for (int i=0; i<10; i++) {<br>
runnable.run();<br>
}<br>
<br>
// give the JIT time to run, and get GC to run - GC can be
stubborn sometimes<br>
</font><font face="Tahoma">for (int i=0; i<3; i++) {<br>
</font><font face="Tahoma">Thread.sleep(100);<br>
</font><font face="Tahoma">System.gc();<br>
}<br>
<br>
// need 20 runs to get a decent average and standard deviation<br>
ArithmeticMean mean = new ArithmeticMean(); // these two classes
are in jakarata-commons-math<br>
</font><font face="Tahoma">Variance deviation = new Variance();<br>
</font><font face="Tahoma">for (int i=0; i<20; i++) {<br>
long time1 = System.currentTimeNanos();<br>
runnable.run();<br>
</font><font face="Tahoma"> long time2 = System.currentTimeNanos();<br>
mean.increment(time2 - time1);<br>
deviation</font><font face="Tahoma">.increment(time2 - time1);</font><br>
<font face="Tahoma">}<br>
<br>
System.out.println("result = " + mean.getMean() + " +- " +
deviation.getVariance());<br>
</font><br>
Regards, Noel Grandin<br>
<br>
Rolf wrote:
<blockquote cite="mid:4E9781E5.1080609@tuis.net" type="cite">Hi all.
<br>
<br>
I have put together a 'simple' system for measuring the relative
performance of JDOM2. The idea is that I need to know whether I am
improving or breaking JDOM performance as the code evolves.
<br>
<br>
Currently the metric code is only useful of you compare apples to
apples, and, in this case, it means processing a single (medium
size) XML document on my laptop, yada-yada-yada. But, it should be
useful as a tool to get a feel for what a code-change does.
<br>
<br>
Already I can see that I probably have an issue in the SAXHandler
(possibly an issue in JDOM-1.1.2 actually) because 1.1.2 is
5-times faster in that area than JDOM2.
<br>
<br>
I have put together a results page here:
<br>
<br>
<a class="moz-txt-link-freetext" href="http://hunterhacker.github.com/jdom/jdom2/performance.html">http://hunterhacker.github.com/jdom/jdom2/performance.html</a>
<br>
<br>
It also describes what each test does. If you are interested in
seeing the code and what it does have a look here (it is not well
documented and it is still perhaps evolving):
<br>
<br>
<a class="moz-txt-link-freetext" href="https://github.com/hunterhacker/jdom/commit/8b719c86913398ace8e197b6de145b33d9d300bb">https://github.com/hunterhacker/jdom/commit/8b719c86913398ace8e197b6de145b33d9d300bb</a>
<br>
<br>
<br>
Rolf
<br>
_______________________________________________
<br>
To control your jdom-interest membership:
<br>
<a class="moz-txt-link-freetext" href="http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com">http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com</a>
<br>
<br>
</blockquote>
<br><br><br><hr><font size="-2" color=808080>Disclaimer: <a href="http://www.peralex.com/disclaimer.html">http://www.peralex.com/disclaimer.html</a><br><br>
</body>
</html>