/* The following static fields will be used by multiple fragments */ public static MethodInvocationBarChart methodInvocationObject = new MethodInvocationBarChart(); public static MethodTimePieChart methodExecutionObject = new MethodTimePieChart(); public static Hashtable methodStartTime = new Hashtable(); static { try { /* Invoke MethodInvocationBarChart.pack() */ methodInvocationObject.pack(); /* Invoke MethodTimePieChart.pack() */ methodExecutionObject.pack(); /* Invoke RefineryUtilities.positionFrameOnScreen() */ org.jfree.ui.RefineryUtilities.positionFrameOnScreen(methodExecutionObject, 0, 0.84); /* Invoke MethodInvocationBarChart.setVisible(true) */ methodInvocationObject.setVisible(true); /* Invoke MethodTimePieChart.setVisible(true) */ methodExecutionObject.setVisible(true); } catch (Exception e) { System.err.println("An exception has occured: " + e.getMessage()); e.printStackTrace(); } } /* Make sure our object is not NULL before continuing */ if (methodInvocationObject != null) { try { /* Get the number of times this method has been executed before */ int previousValue = methodInvocationObject.getMethodCount(methodName); previousValue++; /* Update method counts */ methodInvocationObject.updateMethodCount(methodName, previousValue); /* Graph the method only if it has been invoked more than 2500 times */ if (previousValue >= 2500) { methodInvocationObject.includeMethod(++previousValue, methodName); } /* Store the start time of the method */ methodStartTime.put(methodName, new Long(new Date().getTime())); } catch (Exception e) { System.err.println("An exception occured while trying to execute the methods of MethodInvocationBarChart: " + e.getMessage()); e.printStackTrace(); } } /* Get the start time of the method */ Long methodStartTimeObject = (Long)methodStartTime.get(methodName); if (methodStartTimeObject == null) return; long startTime = methodStartTimeObject.longValue(); /* Remove this entry from our hashtable. Makes things a little more optimum */ methodStartTime.remove(methodName); /* Calculate the execution time of the method (in ms)*/ double executionTime = (double)((new Date().getTime()) - startTime) / (double)1000; /* We're only interested if the execution time is > than 3 second */ if (executionTime >= 3) { try { DecimalFormat df = new DecimalFormat("0.##"); /* Graph the execution time of this method */ methodExecutionObject.includeMethod(Double.parseDouble(df.format(executionTime)), methodName); } catch (Exception e) { System.err.println("An exception occured while trying to execute the methods of methodInvocationObject"); e.printStackTrace(); } }