private void addTiming(CtClass clas, String mname, ClassInstrumentationInfo cii) throws NotFoundException, CannotCompileException, IOException {
// get the method information
StringBuffer before = new StringBuffer().append("{");
StringBuffer after = new StringBuffer().append("{");
MethodInstrumentation mi = cii.getMethod(mname);
CtMethod oldMethod = clas.getDeclaredMethod(mname);
oldMethod.addLocalVariable("_eurekaJTimingStart", CtClass.longType);
//CtClass stackTraceClass = classPool.get("org.eurekaJ.agent.model.CallStackTraceBuilder");
//oldMethod.addLocalVariable("_eurekaJStackTraceBuilder", stackTraceClass);
if (clas.getPackageName().endsWith("sql") || clas.getName().endsWith("Statement")) {
log.info("\n\n\n\t\t\tSQL Instrumetation: " + clas.getPackageName() + " ::: " + clas.getName());
}
before.append("_eurekaJTimingStart = System.currentTimeMillis();\n");
//before.append("org.eurekaJ.agent.model.CallStackTraceBuilderFactory.getCallStackTraceBuilder().enter(\"" + mname + "\", \"" + oldMethod.getSignature() + "\", \"" + clas.getName() + "\", \"" + mi.getClassType() + "\", \"" + cii.getPath() + "\",_eurekaJTimingStart);\n");
// Report statistic for this classtype only (overall)
after.append("org.eurekaJ.agent.EurekaJStringLogger.addGroupStatistics(\"" + mi.getClassType()
+ "\", (System.currentTimeMillis() - _eurekaJTimingStart), _eurekaJTimingStart, \"" + mi.getClassType() + "\");\n");
// Report statistic for this classtype and path (overall)
after.append("org.eurekaJ.agent.EurekaJStringLogger.addGroupStatistics(\"" + mi.getClassType() + ":" + cii.getPath()
+ "\", (System.currentTimeMillis() - _eurekaJTimingStart), _eurekaJTimingStart, \"" + mi.getClassType() + "\");\n");
// Report statistic for this classtype, path and class (overall)
after.append("org.eurekaJ.agent.EurekaJStringLogger.addGroupStatistics(\"" + mi.getClassType() + ":" + cii.getPath() + ":" + clas.getName()
+ "\", (System.currentTimeMillis() - _eurekaJTimingStart), _eurekaJTimingStart, \"" + mi.getClassType() + "\");\n");
// Report statistic for this method call (classtype, path, class and method)
after.append("org.eurekaJ.agent.EurekaJStringLogger.addStatistic(\"" + clas.getName() + " " + mname
+ "\", (System.currentTimeMillis() - _eurekaJTimingStart), _eurekaJTimingStart, \"" + mi.getClassType() + "\", \"" + cii.getPath() + "\");\n");
//after.append("org.eurekaJ.agent.model.CallStackTraceBuilderFactory.getCallStackTraceBuilder().leave(System.currentTimeMillis() - _eurekaJTimingStart);\n");
oldMethod.insertBefore(before.append("}").toString());