package listener; import gov.nasa.jpf.ListenerAdapter; import gov.nasa.jpf.vm.VM; import gov.nasa.jpf.vm.VMListener; /** * This listener prints the amount of time (in milliseconds) taken by the garbage * collector each time the garbage collector is invoked. * * @author Franck van Breugel */ public class Garbage extends ListenerAdapter implements VMListener { private long start; // when the garbage collector was last started /** * Whenever the garbage collector starts, records the current time. * * @param vm JPF's VM */ @Override public void gcBegin(VM vm) { this.start = System.currentTimeMillis(); } /** * Whenever the garbage collector ends, prints the amount of time it has taken. * * @param vm JPF's VM */ public void gcEnd(VM vm) { System.out.println(System.currentTimeMillis() - this.start); } }