/** * Start a timer of the given string name for all todos and the current * thread. If no such timer exists yet, then it will be newly created. * * @param timerName * the name of the timer */ public static void startNamedTimer(String timerName) { getNamedTimer(timerName).start(); }
/** * Print logging information for the timer using debug priority. * * @see org.semanticweb.elk.util.logging.ElkTimer#log(Logger,Priority) log() * @param logger */ public void log(Logger logger) { log(logger, Level.DEBUG); }
public static void logAllNamedTimers(String timerName, Logger logger) { logAllNamedTimers(timerName, logger, Level.DEBUG); }
/** * Reset a timer of the given string name for the current thread. If no such * timer exists yet, then it will be newly created. * * @param timerName * the name of the timer * @param todoFlags */ public static void resetNamedTimer(String timerName, int todoFlags) { getNamedTimer(timerName, todoFlags).reset(); }
/** * Log the end of a particular operation the beginning of which has been * logged using logOperationStart(), using the given logging priority. * * @param operationName * @param logger * @param priority */ public static void logOperationFinish(String operationName, Logger logger, Priority priority) { if (logger.isEnabledFor(priority)) { ElkTimer timer = ElkTimer.getNamedTimer(operationName, ElkTimer.RECORD_WALLTIME); timer.stop(); logger.log(priority, operationName + " took " + timer.getTotalWallTime() / 1000000 + " ms"); } }
/** * Log the start of a particular operation with the given priority. This * method should be used for long-running tasks and is mainly intended. * Multiple threads can independently log operations of the same name, but * (obviously) no single thread should use the same operation name to record * the start and end of overlapping code. * * @param operationName * @param logger * @param priority */ public static void logOperationStart(String operationName, Logger logger, Priority priority) { if (logger.isEnabledFor(priority)) { logger.log(priority, operationName + " started"); ElkTimer timer = ElkTimer.getNamedTimer(operationName, ElkTimer.RECORD_WALLTIME); timer.reset(); // needed in case this was done before timer.start(); } }
@Override public void execute(ReasonerStage stage) throws ElkException { super.execute(stage); // FIXME: get rid of casts try { for (PostProcessingStage ppStage : instantiate( postProcesingMap.get(stage.getClass()), ((AbstractReasonerStage) stage).reasoner)) { ElkTimer.getNamedTimer(ppStage.getName()).start(); ppStage.execute(); ElkTimer.getNamedTimer(ppStage.getName()).stop(); } } catch (Exception e) { throw new ElkRuntimeException(e); } }
/** * Stop a timer of the given string name for the given thread. If no such * timer exists, -1 will be returned. Otherwise the return value is the CPU * time that was measured. * * @param timerName * the name of the timer * @param todoFlags * @param threadId * of the thread to track, or 0 if only system clock should be * tracked * @return CPU time if timer existed and was running, and -1 otherwise */ public static long stopNamedTimer(String timerName, int todoFlags, long threadId) { ElkTimer key = new ElkTimer(timerName, todoFlags, threadId); if (registeredTimers.containsKey(key)) { return registeredTimers.get(key).stop(); } else { return -1; } }
/** * Get a timer of the given string name that takes all possible times * (todos) for the current thread. If no such timer exists yet, then it will * be newly created. * * @param timerName * the name of the timer * @return timer */ public static ElkTimer getNamedTimer(String timerName) { return getNamedTimer(timerName, RECORD_ALL, Thread.currentThread() .getId()); }
/** * * @param name * @param todoFlags * @return a new {@link ElkTimer} for the current thread */ static public ElkTimer getTimerForCurrentThread(String name, int todoFlags) { return new ElkTimer(name, todoFlags, Thread.currentThread().getId()); }
/** * Stop a timer of the given string name for all todos and the current * thread. If no such timer exists, -1 will be returned. Otherwise the * return value is the CPU time that was measured. * * @param timerName * the name of the timer * @return CPU time if timer existed and was running, and -1 otherwise */ public static long stopNamedTimer(String timerName) { return stopNamedTimer(timerName, RECORD_ALL, Thread.currentThread() .getId()); }
/** * Start the timer. */ public synchronized void start() { if ((todoFlags & RECORD_CPUTIME) != 0) { currentStartCpuTime = getThreadCpuTime(threadId); } else { currentStartCpuTime = -1; } if ((todoFlags & RECORD_WALLTIME) != 0) { currentStartWallTime = System.nanoTime(); } else { currentStartWallTime = -1; } isRunning = true; }
/** * Reset a timer of the given string name for all todos and the current * thread. If no such timer exists yet, then it will be newly created. * * @param timerName * the name of the timer */ public static void resetNamedTimer(String timerName) { getNamedTimer(timerName).reset(); }
/** * Log the end of a particular operation the beginning of which has been * logged using logOperationStart(), using the given logging priority. * * @param operationName * @param logger * @param priority */ public static void logOperationFinish(String operationName, Logger logger, LogLevel priority) { if (LoggerWrap.isEnabledFor(logger, priority)) { ElkTimer timer = ElkTimer.getNamedTimer(operationName, ElkTimer.RECORD_WALLTIME); timer.stop(); LoggerWrap.log(logger, priority, operationName + " took " + timer.getTotalWallTime() / 1000000 + " ms"); } }
/** * Log the start of a particular operation with the given priority. This * method should be used for long-running tasks and is mainly intended. * Multiple threads can independently log operations of the same name, but * (obviously) no single thread should use the same operation name to record * the start and end of overlapping code. * * @param operationName * @param logger * @param priority */ public static void logOperationStart(String operationName, Logger logger, LogLevel priority) { if (LoggerWrap.isEnabledFor(logger, priority)) { LoggerWrap.log(logger, priority, operationName + " started"); ElkTimer timer = ElkTimer.getNamedTimer(operationName, ElkTimer.RECORD_WALLTIME); timer.reset(); // needed in case this was done before timer.start(); } }
/** * Stop a timer of the given string name for the given thread. If no such * timer exists, -1 will be returned. Otherwise the return value is the CPU * time that was measured. * * @param timerName * the name of the timer * @param todoFlags * @param threadId * of the thread to track, or 0 if only system clock should be * tracked * @return CPU time if timer existed and was running, and -1 otherwise */ public static long stopNamedTimer(String timerName, int todoFlags, long threadId) { ElkTimer key = new ElkTimer(timerName, todoFlags, threadId); if (registeredTimers.containsKey(key)) { return registeredTimers.get(key).stop(); } else { return -1; } }
/** * Get a timer of the given string name and todos for the current thread. If * no such timer exists yet, then it will be newly created. * * @param timerName * the name of the timer * @param todoFlags * @return timer */ public static ElkTimer getNamedTimer(String timerName, int todoFlags) { return getNamedTimer(timerName, todoFlags, Thread.currentThread() .getId()); }
/** * * @param name * @param todoFlags * @return a new {@link ElkTimer} for the current thread */ static public ElkTimer getTimerForCurrentThread(String name, int todoFlags) { return new ElkTimer(name, todoFlags, Thread.currentThread().getId()); }
/** * Stop a timer of the given string name for all todos and the current * thread. If no such timer exists, -1 will be returned. Otherwise the * return value is the CPU time that was measured. * * @param timerName * the name of the timer * @return CPU time if timer existed and was running, and -1 otherwise */ public static long stopNamedTimer(String timerName) { return stopNamedTimer(timerName, RECORD_ALL, Thread.currentThread() .getId()); }
/** * Start the timer. */ public synchronized void start() { if ((todoFlags & RECORD_CPUTIME) != 0) { currentStartCpuTime = getThreadCpuTime(threadId); } else { currentStartCpuTime = -1; } if ((todoFlags & RECORD_WALLTIME) != 0) { currentStartWallTime = System.nanoTime(); } else { currentStartWallTime = -1; } isRunning = true; }