/** * {@inheritDoc} */ @Override public QueryResult exec(final Query query) { _logger.fine(() -> "Executing query " + query); final Timer timer = new Timer("CombinedQueryEngine"); timer.start(); prepare(query); branches = 0; exec(new ResultBindingImpl()); timer.stop(); _logger.fine(() -> "#B=" + branches + ", time=" + timer.getLast() + " ms."); return _result; }
/** * Set a timeout for the main timer. Used to stop an automated test after a reasonable amount of time has passed. * * @param timeout */ @Override public void setTimeout(final long timeout) { _logger.info(() -> "Timeout @ " + timeout + "ms"); _timers._mainTimer.setTimeout(timeout); }
long t1 = o1.getTotal(); long t2 = o2.getTotal(); if (t1 == 0) t1 = o1.getElapsed(); if (t2 == 0) t2 = o2.getElapsed(); return (int) (t2 - t1); return (int) (o2.getAverage() - o1.getAverage()); else if (sortBy.equalsIgnoreCase("Count")) return (int) (o2.getCount() - o1.getCount()); else return AlphaNumericComparator.CASE_INSENSITIVE.compare(o1, o2); row.add(timer.getName()); if (!shortForm) row.add(String.valueOf(timer.getCount())); row.add(nf.format(timer.getAverage())); if (timer.isStarted()) row.add(String.valueOf(timer.getElapsed())); else row.add(String.valueOf(timer.getTotal())); table.add(row);
@Override public String toString() { if (_startCount > 0) return "Timer " + _name + " Avg: " + getAverage() + " Count: " + _count + " Total: " + getTotal() + " Still running: " + _startCount; return "Timer " + _name + " Avg: " + getAverage() + " Count: " + _count + " Total: " + getTotal(); }
private TaxonomyNode<ATermAppl> checkSatisfiability(final ATermAppl c) { _logger.finer("Satisfiable "); final Optional<Timer> timer = _kb.getTimers().startTimer("classifySat"); boolean isSatisfiable = _kb.getABox().isSatisfiable(c, true); timer.ifPresent(t -> t.stop()); if (_logger.isLoggable(Level.FINER) && timer.isPresent()) _logger.finer((isSatisfiable ? "true" : "*****FALSE*****") + " (" + timer.get().getLast() + "ms)"); if (!isSatisfiable) _taxonomyImpl.addEquivalentNode(c, _taxonomyImpl.getBottomNode()); if (OpenlletOptions.USE_CACHING) { if (_logger.isLoggable(Level.FINER)) _logger.finer("...negation "); final Optional<Timer> timer2 = _kb.getTimers().startTimer("classifySatNot"); final ATermAppl notC = ATermUtils.makeNot(c); isSatisfiable = _kb.getABox().isSatisfiable(notC, true); timer2.ifPresent(t -> t.stop()); if (!isSatisfiable) _taxonomyImpl.addEquivalentNode(c, _taxonomyImpl.getTop()); if (_logger.isLoggable(Level.FINER) && timer2.isPresent()) _logger.finer(isSatisfiable + " (" + timer2.get().getLast() + "ms)"); } return _taxonomyImpl.getNode(c); }
@Override public void taskFinished() { _timer.stop(); }
t.start(); classifier.classify(); t.stop(); System.out.println("\nClassification time: " + t.getTotal() + "ms"); System.out.println("Subclasses of " + pain + ": " + classifier.getSubClasses(pain, true).entities().map(OWLClass::toString).collect(Collectors.joining(",")) + "\n"); t.start(); classifier.classify(); t.stop(); System.out.println("\nClassification time: " + t.getTotal() + "ms"); System.out.println("Subclasses of " + pain + ": " + classifier.getSubClasses(pain, true).entities().map(OWLClass::toString).collect(Collectors.joining(",")) + "\n"); timers.stopTimer("Third classification"); System.out.println("\nClassification time: " + t.getTotal() + "ms"); System.out.println("Subclasses of " + pain + ": " + classifier.getSubClasses(pain, true).entities().map(OWLClass::toString).collect(Collectors.joining(",")) + "\n"); if (!timer.isStarted()) System.out.println(timer.getName() + ": " + timer.getTotal() + "ms");
private static QueryResult runSingleTest(final Query query) { final Timer t = new Timer("Single _query execution"); t.start(); final QueryResult bindings = QueryEngine.exec(query); _logger.info("Execution time=" + t.getElapsed()); t.stop(); _logger.info("Result size = " + bindings.size()); return bindings; }
@Override public boolean isSubClassOf(final ATermAppl c1, final ATermAppl c2) { if (!_doExplanation) { final Bool isKnownSubClass = isKnownSubClassOf(c1, c2); if (isKnownSubClass.isKnown()) return isKnownSubClass.isTrue(); } if (_logger.isLoggable(Level.FINE)) { final long count = _kb.getTimers().getTimer("subClassSat").map(t -> t.getCount()).orElse(0L); _logger.fine(count + ") Checking subclass [" + ATermUtils.toString(c1) + " " + ATermUtils.toString(c2) + "]"); } final ATermAppl notC2 = ATermUtils.negate(c2); final ATermAppl c = ATermUtils.makeAnd(c1, notC2); final Optional<Timer> timer = _kb.getTimers().startTimer("subClassSat"); final boolean sub = !isSatisfiable(c, false); timer.ifPresent(t -> t.stop()); _logger.fine(() -> " Result: " + sub + timer.map(t -> " (" + t.getLast() + "ms)").orElse("")); return sub; }
public void classify() { System.out.println("Classify Timeout: " + Timeouts.CLASSIFY + "ms"); System.out.print("Classifying..."); try { ((PelletInfGraph) model.getGraph()).classify(); System.out.println("finished in " + timers.getTimer("classify").get().getLast() + "ms"); } catch (final TimeoutException e) { Log.error(_logger, e); System.out.println("interrupted after " + timers.getTimer("classify").get().getElapsed() + "ms"); } System.out.println("Classified: " + openllet.isClassified()); System.out.println(); }
/** * Check if the elapsed time is greater than the timeout limit and throw a TimeoutException if that is the case. Check the parent timer if there is one. * * @throws TimeoutException * @throws TimerInterruptedException */ public void check() throws TimeoutException, TimerInterruptedException { if (interrupted) { interrupted = false; throw new TimerInterruptedException("Timer " + getName() + " interrupted."); } final long elapsed = getElapsed(); if (_timeout != NO_TIMEOUT && elapsed > _timeout) throw new TimeoutException("Running time of " + _name + " exceeded timeout of " + _timeout); if (_parent != null) _parent.check(); }
@Override public void taskStarted() { resetProgress(); _timer.start(); }
public void consistency() throws TimeoutException { System.out.println("Consistency Timeout: " + Timeouts.CONSISTENCY + "ms"); System.out.print("Checking consistency..."); model.prepare(); System.out.println("finished in " + timers.getTimer("isConsistent").get().getLast()); System.out.println(); }
public String format() { return DurationFormat.LONG.format(getTotal() + getElapsed()); } }
@Override public boolean isCanceled() { final long elapsedTime = _timer.getElapsed(); return elapsedTime > _limit; } }
public void execQuery(final Query query) { System.out.print("Running SPARQL query..."); // we need to restart the timer as above timers._mainTimer.restart(); try { // run the SPARQL query final ResultSet results = SparqlDLExecutionFactory.create(query, model).execSelect(); final int size = ResultSetFormatter.consume(results); System.out.print("completed in " + timers._mainTimer.getElapsed() + "ms"); System.out.println(" (" + size + " results)"); } catch (final TimeoutException e) { Log.error(_logger, e); System.out.println("interrupted after " + timers._mainTimer.getElapsed() + "ms"); } } }