/** Creates a string with information including the passed message, the last passed message and the time since the last call, and the time since the beginning * @param message A message to put into the timer String * @param module The debug/log module/thread to use, can be null for root module * @return A String with the timing information, the timer String */ public String timerString(String message, String module) { // time this call to avoid it interfering with the main timer long tsStart = System.currentTimeMillis(); String retString = "[[" + message + "- total:" + secondsSinceStart() + ",since last(" + ((lastMessage.length() > 20) ? (lastMessage.substring(0, 17) + "...") : lastMessage) + "):" + secondsSinceLast() + "]]"; lastMessage = message; if (log) Debug.log(Debug.TIMING, null, retString, module, "org.ofbiz.core.util.UtilTimer"); // have lastMessageTime come as late as possible to just time what happens between calls lastMessageTime = System.currentTimeMillis(); // update startTime to disclude the time this call took startTime += (lastMessageTime - tsStart); return retString; }
/** Creates a string with information including the passed message, the last passed message and the time since the last call, and the time since the beginning * @param message A message to put into the timer String * @param module The debug/log module/thread to use, can be null for root module * @return A String with the timing information, the timer String */ public String timerString(String message, String module) { // time this call to avoid it interfering with the main timer long tsStart = System.currentTimeMillis(); String retString = "[[" + message + "- total:" + secondsSinceStart() + ",since last(" + ((lastMessage.length() > 20) ? (lastMessage.substring(0, 17) + "...") : lastMessage) + "):" + secondsSinceLast() + "]]"; lastMessage = message; if (log) Debug.log(Debug.TIMING, null, retString, module, "org.ofbiz.core.util.UtilTimer"); // have lastMessageTime come as late as possible to just time what happens between calls lastMessageTime = System.currentTimeMillis(); // update startTime to disclude the time this call took startTime += (lastMessageTime - tsStart); return retString; }