Skip to content

Commit

Permalink
total time for imports and exports is printed
Browse files Browse the repository at this point in the history
  • Loading branch information
clausnagel committed Jan 28, 2015
1 parent 4cbab02 commit 88100b9
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ public boolean doProcess() {

int rows = useTiling ? tiling.getRows() : 1;
int columns = useTiling ? tiling.getColumns() : 1;

long start = System.currentTimeMillis();

for (int i = 0; shouldRun && i < rows; i++) {
for (int j = 0; shouldRun && j < columns; j++) {

Expand Down Expand Up @@ -620,7 +621,10 @@ public boolean doProcess() {
if (geometryObjects != 0)
LOG.info("Total processed geometry objects: " + geometryObjects);
}


if (shouldRun)
LOG.info("Total export time: " + Util.formatElapsedTime(System.currentTimeMillis() - start) + ".");

return shouldRun;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
import org.citydb.modules.common.filter.FilterMode;
import org.citydb.modules.common.filter.ImportFilter;
import org.citydb.modules.common.filter.statistic.FeatureCounterFilter;
import org.citydb.util.Util;
import org.citygml4j.builder.jaxb.JAXBBuilder;
import org.citygml4j.model.citygml.CityGML;
import org.citygml4j.model.citygml.CityGMLClass;
Expand Down Expand Up @@ -268,7 +269,8 @@ public boolean accept(CityGMLClass type) {
WorkerPool<DBXlink> xlinkResolverPool = null;
DBXlinkSplitter tmpSplitter = null;
ImportLogger importLogger = null;

long start = System.currentTimeMillis();

while (shouldRun && fileCounter < importFiles.size()) {
try {
// check whether we reached the counter limit
Expand Down Expand Up @@ -568,6 +570,9 @@ public boolean accept(CityGMLClass type) {

if (geometryObjects != 0)
LOG.info("Processed geometry objects: " + geometryObjects);

if (shouldRun)
LOG.info("Total import time: " + Util.formatElapsedTime(System.currentTimeMillis() - start) + ".");

return shouldRun;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import org.citydb.modules.common.event.StatusDialogMessage;
import org.citydb.modules.common.event.StatusDialogProgressBar;
import org.citydb.modules.common.event.StatusDialogTitle;
import org.citydb.util.Util;
import org.citygml4j.xml.schema.SchemaHandler;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
Expand All @@ -74,10 +75,6 @@ public class XMLValidator implements EventHandler {
private boolean reportAllErrors;
private InputStream inputStream;

private int runState;
private final int PREPARING = 1;
private final int VALIDATING = 2;

public XMLValidator(Config config, EventDispatcher eventDispatcher) {
this.config = config;
this.eventDispatcher = eventDispatcher;
Expand All @@ -88,8 +85,6 @@ public void cleanup() {
}

public boolean doProcess() {
runState = PREPARING;

// adding listeners
eventDispatcher.addEventHandler(EventType.INTERRUPT, this);

Expand Down Expand Up @@ -127,8 +122,8 @@ public boolean doProcess() {
return false;
}

runState = VALIDATING;

long start = System.currentTimeMillis();
while (shouldRun && fileCounter < importFiles.size()) {
File file = importFiles.get(fileCounter++);
intConfig.setImportPath(file.getParent());
Expand Down Expand Up @@ -161,7 +156,10 @@ public boolean doProcess() {
LOG.warn(errorHandler.errors + " error(s) reported while validating the document.");
else if (errorHandler.errors == 0 && shouldRun)
LOG.info("The CityGML file is valid.");
}
}

if (shouldRun)
LOG.info("Total validation time: " + Util.formatElapsedTime(System.currentTimeMillis() - start) + ".");

return shouldRun;
}
Expand All @@ -183,10 +181,10 @@ public void handleEvent(Event e) throws Exception {
if (log != null)
LOG.log(interruptEvent.getLogLevelType(), log);

if (runState == PREPARING && directoryScanner != null)
if (directoryScanner != null)
directoryScanner.stopScanning();

if (runState == VALIDATING && inputStream != null)
if (inputStream != null)
inputStream.close();
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/org/citydb/modules/kml/controller/KmlExporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
import org.citydb.modules.kml.database.WaterBody;
import org.citydb.modules.kml.datatype.TypeAttributeValueEnum;
import org.citydb.modules.kml.util.CityObject4JSON;
import org.citydb.util.Util;
import org.citygml4j.model.citygml.CityGMLClass;
import org.citygml4j.util.xml.SAXEventBuffer;
import org.citygml4j.util.xml.SAXFragmentWriter;
Expand Down Expand Up @@ -323,6 +324,8 @@ public boolean doProcess() {
columns = 1;
}

long start = System.currentTimeMillis();

for (DisplayForm displayForm : config.getProject().getKmlExporter().getBuildingDisplayForms()) {
if (!displayForm.isActive()) continue;

Expand Down Expand Up @@ -625,6 +628,9 @@ public boolean doProcess() {

if (lastTempFolder != null && lastTempFolder.exists()) deleteFolder(lastTempFolder); // just in case

if (shouldRun)
Logger.getInstance().info("Total export time: " + Util.formatElapsedTime(System.currentTimeMillis() - start) + ".");

return shouldRun;
}

Expand Down
21 changes: 19 additions & 2 deletions src/org/citydb/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.concurrent.TimeUnit;
import java.util.regex.PatternSyntaxException;

import org.citydb.config.internal.Internal;
Expand Down Expand Up @@ -318,7 +319,7 @@ public static List<Code> string2codeList(String values, String codespaces) {

return codeList;
}

public static String buildInOperator(Collection<? extends Object> items, String columnName, String logicalOperator, int maxItems) {
StringBuilder predicate = new StringBuilder();
if (items.size() == 1)
Expand Down Expand Up @@ -391,6 +392,22 @@ public static String stripFileExtension(String file) {
return file;
}

public static String formatElapsedTime(long millis) {
long d = TimeUnit.MILLISECONDS.toDays(millis);
long h = TimeUnit.MILLISECONDS.toHours(millis) % TimeUnit.DAYS.toHours(1);
long m = TimeUnit.MILLISECONDS.toMinutes(millis) % TimeUnit.HOURS.toMinutes(1);
long s = TimeUnit.MILLISECONDS.toSeconds(millis) % TimeUnit.MINUTES.toSeconds(1);

if (d > 0)
return String.format("%02d d, %02d h, %02d m, %02d s", d, h, m, s);
if (h > 0)
return String.format("%02d h, %02d m, %02d s", h, m, s);
if (m > 0)
return String.format("%02d m, %02d s", m, s);

return String.format("%02d s", s);
}

public static boolean checkWorkspaceTimestamp(Workspace workspace) {
String timestamp = workspace.getTimestamp().trim();
boolean success = true;
Expand Down Expand Up @@ -456,7 +473,7 @@ else if (parent instanceof Child)

return null;
}

public static CityGMLVersion toCityGMLVersion(CityGMLVersionType version) {
switch (version) {
case v1_0_0:
Expand Down

0 comments on commit 88100b9

Please sign in to comment.