Skip to content

Performance optimization

Paul Schwartz edited this page Apr 18, 2015 · 1 revision

Setting up performance monitoring on the Tomcat VM may be more than we want sometimes. To get around that we have a class us.mn.state.health.lims.common.tools.StopWatch which will let us mark the time it takes certain events and then prints the results to the console. More details can be found in the JavaDocs but the general process is to

  • Create a StopWatch stopwatch =new StopWatch();
  • Start it stopwatch.start("What you want at the top of the print out" );
  • Put a mark where you think something interesting may have happened stopwatch.setMark("Note about the the mark");
  • Print out all of the results stopwatch.report();

By example:

`StopWatch sw = new StopWatch()
sw.start("Logbook timing");
----existing code ----------
sw.setMark("properties set");
----existing code ----------
sw.setMark("paging done");
----existing code ----------
sw.setMark("finished");
sw.report();`		

The result printed to console is

`Logbook timing
	accum	period
properties set	0.106   0.106
paging done	13.962   13.856
finished	13.962	   0.000`

There is also a disable(boolean) method which will suppress any actions. This is a convenience method to allow the code to remain in place but be turned on or off.

Clone this wiki locally