use of de.lmu.ifi.dbs.elki.result.ResultHierarchy in project elki by elki-project.
the class AlgorithmStep method runAlgorithms.
/**
* Run algorithms.
*
* @param database Database
* @return Algorithm result
*/
public Result runAlgorithms(Database database) {
ResultHierarchy hier = database.getHierarchy();
if (LOG.isStatistics()) {
boolean first = true;
for (It<Index> it = hier.iterDescendants(database).filter(Index.class); it.valid(); it.advance()) {
if (first) {
LOG.statistics("Index statistics before running algorithms:");
first = false;
}
it.get().logStatistics();
}
}
stepresult = new BasicResult("Algorithm Step", "algorithm-step");
for (Algorithm algorithm : algorithms) {
Thread.currentThread().setName(algorithm.toString());
Duration duration = LOG.isStatistics() ? LOG.newDuration(algorithm.getClass().getName() + ".runtime").begin() : null;
Result res = algorithm.run(database);
if (duration != null) {
LOG.statistics(duration.end());
}
if (LOG.isStatistics()) {
boolean first = true;
for (It<Index> it = hier.iterDescendants(database).filter(Index.class); it.valid(); it.advance()) {
if (first) {
LOG.statistics("Index statistics after running algorithm " + algorithm.toString() + ":");
first = false;
}
it.get().logStatistics();
}
}
if (res != null) {
// Make sure the result is attached, but usually this is a noop:
hier.add(database, res);
}
}
return stepresult;
}
Aggregations