Re: JDOM2 and Performance.

Noel Grandin <[email protected]>
Newsgroups gmane.comp.java.jdom.general
Message-ID <[email protected]>
Hi

Performance testing on the Java VM is tricky.
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)

// warm up the caches and get the JIT going
for (int i=0; i<10; i++) {
   runnable.run();
}

// give the JIT time to run, and get GC to run - GC can be stubborn sometimes
for (int i=0; i<3; i++) {
   Thread.sleep(100);
   System.gc();
}

// need 20 runs to get a decent average and standard deviation
ArithmeticMean mean = new ArithmeticMean(); // these two classes are in jakarata-commons-math
Variance deviation = new Variance();
for (int i=0; i<20; i++) {
  long time1 = System.currentTimeNanos();
  runnable.run();
  long time2 = System.currentTimeNanos();
  mean.increment(time2 - time1);
  deviation.increment(time2 - time1);
}

System.out.println("result  = " + mean.getMean() + " +- " + deviation.getVariance());

Regards, Noel Grandin

Rolf wrote:
> Hi all.
>
> 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.
>
> 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.
>
> 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.
>
> I have put together a results page here:
>
> http://hunterhacker.github.com/jdom/jdom2/performance.html
>
> 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):
>
> https://github.com/hunterhacker/jdom/commit/8b719c86913398ace8e197b6de145b33d9d300bb
>
>
> Rolf
> _______________________________________________
> To control your jdom-interest membership:
> http://www.jdom.org/mailman/options/jdom-interest/[email protected]
>

Disclaimer: http://www.peralex.com/disclaimer.html

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.