2 Minutes To Code (β Version)

Simon - 2 minute tutorial

How to profile a single event/method in a java class

This example shows how to use Simon apis to record statictics about events.

First, you need to get an object of class org.javasimon.Stopwatch and giving it any appropriate name. Then start the stopwatch and get a org.javasimon.Split object from it. Then call the event that you need to gather statistics about and finally stop the stopwatch by calling stop() method on the Split object.

That is all one needs to do. The stopwatch internally keeps track of all these events and collects statictics.

The methods that Stopwatch and Sample (provided by sample() method of Stopwatch) objects provide to get the collected statistics are :

getCounter() getTotal() getMean()
getMax() getMin() getLast()
getActive() getMaxActive() getMaxTimestamp()
getStandardDeviation() getVariance() getMinTimestamp()

package com.techfundaes.simonBag;

import org.javasimon.SimonManager;
import org.javasimon.Split;
import org.javasimon.Stopwatch;

public class SimonUseBasic
	public static void main(String[] args)
		Stopwatch stopwatch = SimonManager.getStopwatch("use.basic");
		Split split = stopwatch.start();
		System.out.println(stopwatch.getMax()/1000/1000);		//Convert nano-secs to milli-secs
		System.out.printf("%.2f%n", stopwatch.getMean()/1024/1024);

	private static void doVitalTask()
		catch (Exception e)