views:

707

answers:

1
+2  Q: 

Calculate Throuput

Hi,

I have a the following scenarios. I am trying to calculate throughput of the java's XSLT transformer. I have 10 threrads, each iterates 1000 times. The task of the thread is to read the XML and XSLT file and trasnform it and write to a new file.

I want to calculate the TPS. Can you please suggest the way to calculate TPS?

Thanks and Regards,

Srinivas.

+2  A: 

Well, you want to start a timer at the beginning and stop it when all threads complete. That gives you elapsed time = end time - begin time. Transactions = 10 threads * 1000 iterations = 10000. TPS = 10000 / elapsed time.

The easiest way to do this kind of timing is with a CyclicBarrier. Here's a good writeup of using a barrier action with a CyclicBarrier as a timer (see last example):

My final caveat would be that benchmarking something like this is fraught with peril. Some suggestions:

  • Run more than 1000 iterations. You need to let hotspot warm up. Preferably you should let the test run at least 10 minutes.
  • Don't discount GC times. You need to be aware of what GC you're using and how its pause times are affecting your results. Running with -verbose:gc at least a few times is extremely valuable. See here for more: http://java.sun.com/developer/technicalArticles/Programming/GCPortal/
  • Run multiple repetitions in the same process until you see repeatable results.
  • Do many runs until you believe the numbers are consistent.
Alex Miller