import java.util.HashMap; import java.util.Map; import gov.nasa.jpf.ListenerAdapter; import gov.nasa.jpf.search.Search; import gov.nasa.jpf.search.SearchListener; import gov.nasa.jpf.vm.MethodInfo; import gov.nasa.jpf.vm.ThreadInfo; import gov.nasa.jpf.vm.VM; import gov.nasa.jpf.vm.VMListener; public class Profiler extends ListenerAdapter implements VMListener, SearchListener { private Map map; public Profiler() { this.map = new HashMap(); } public void methodEntered(VM vm, ThreadInfo currentThread, MethodInfo enteredMethod) { String name = enteredMethod.getFullName(); if (!this.map.containsKey(name)) { this.map.put(name, 0); } this.map.put(name, this.map.get(name) + 1); } public void searchFinished(Search search) { int maxValue = 0; String maxName = null; for (String name : this.map.keySet()) { if (this.map.get(name) > maxValue) { maxValue = this.map.get(name); maxName = name; } } System.out.printf("%s: %d%n", maxName, maxValue); } }