Refactor time fields

This commit is contained in:
Victor Shcherb 2020-07-10 20:35:22 +02:00
parent 386c7dc3f4
commit a1cbdc111b
3 changed files with 7 additions and 9 deletions

View file

@ -376,9 +376,9 @@ public class BinaryRoutePlanner {
public static void printDebugMemoryInformation(RoutingContext ctx) { public static void printDebugMemoryInformation(RoutingContext ctx) {
if (ctx.calculationProgress != null) { if (ctx.calculationProgress != null) {
RouteCalculationProgress p = ctx.calculationProgress; RouteCalculationProgress p = ctx.calculationProgress;
printInfo(String.format("Time. Total: %.2f, to load: %.2f, to load headers: %.2f, to calc dev: %.2f ", printInfo(String.format("Time. Total: %.2f, to load: %.2f, to load headers: %.2f, to find start/end: %.2f, extra: %.2f ",
p.timeToCalculate / 1e6, p.timeToLoad / 1e6, p.timeToLoadHeaders / 1e6, p.timeToCalculate / 1e6, p.timeToLoad / 1e6, p.timeToLoadHeaders / 1e6,
p.timeNanoToCalcDeviation / 1e6)); p.timeToFindInitialSegments / 1e6, p.timeNanoToCalcDeviation / 1e6));
// GeneralRouter.TIMER = 0; // GeneralRouter.TIMER = 0;
int maxLoadedTiles = Math.max(p.maxLoadedTiles, ctx.getCurrentlyLoadedTiles()); int maxLoadedTiles = Math.max(p.maxLoadedTiles, ctx.getCurrentlyLoadedTiles());
printInfo("Current loaded tiles : " + ctx.getCurrentlyLoadedTiles() + ", maximum loaded tiles " printInfo("Current loaded tiles : " + ctx.getCurrentlyLoadedTiles() + ", maximum loaded tiles "

View file

@ -122,6 +122,7 @@ public class RoutePlannerFrontEnd {
public RouteSegmentPoint findRouteSegment(double lat, double lon, RoutingContext ctx, List<RouteSegmentPoint> list, boolean transportStop, public RouteSegmentPoint findRouteSegment(double lat, double lon, RoutingContext ctx, List<RouteSegmentPoint> list, boolean transportStop,
boolean allowDuplications) throws IOException { boolean allowDuplications) throws IOException {
long now = System.nanoTime();
int px = MapUtils.get31TileNumberX(lon); int px = MapUtils.get31TileNumberX(lon);
int py = MapUtils.get31TileNumberY(lat); int py = MapUtils.get31TileNumberY(lat);
ArrayList<RouteDataObject> dataObjects = new ArrayList<RouteDataObject>(); ArrayList<RouteDataObject> dataObjects = new ArrayList<RouteDataObject>();
@ -172,6 +173,9 @@ public class RoutePlannerFrontEnd {
return Double.compare(o1.distSquare, o2.distSquare); return Double.compare(o1.distSquare, o2.distSquare);
} }
}); });
if (ctx.calculationProgress != null) {
ctx.calculationProgress.timeToFindInitialSegments += (System.nanoTime() - now);
}
if (list.size() > 0) { if (list.size() > 0) {
RouteSegmentPoint ps = null; RouteSegmentPoint ps = null;
if (ctx.publicTransport) { if (ctx.publicTransport) {
@ -275,7 +279,6 @@ public class RoutePlannerFrontEnd {
start = next; start = next;
} }
if(gctx.ctx.calculationProgress != null) { if(gctx.ctx.calculationProgress != null) {
// TODO
gctx.ctx.calculationProgress.timeToCalculate = System.nanoTime() - timeToCalculate; gctx.ctx.calculationProgress.timeToCalculate = System.nanoTime() - timeToCalculate;
} }
BinaryRoutePlanner.printDebugMemoryInformation(gctx.ctx); BinaryRoutePlanner.printDebugMemoryInformation(gctx.ctx);
@ -664,8 +667,7 @@ public class RoutePlannerFrontEnd {
res = searchRouteImpl(ctx, points, routeDirection); res = searchRouteImpl(ctx, points, routeDirection);
} }
if (ctx.calculationProgress != null) { if (ctx.calculationProgress != null) {
// TODO ctx.calculationProgress.timeToCalculate = System.nanoTime() - timeToCalculate;
ctx.calculationProgress.timeToCalculate = System.nanoTime() - timeToCalculate;
} }
BinaryRoutePlanner.printDebugMemoryInformation(ctx); BinaryRoutePlanner.printDebugMemoryInformation(ctx);
if (res != null) { if (res != null) {

View file

@ -420,7 +420,6 @@ public class RoutingContext {
} }
TLongHashSet ts = new TLongHashSet(); TLongHashSet ts = new TLongHashSet();
long now = System.nanoTime();
for(int i = -t; i <= t; i++) { for(int i = -t; i <= t; i++) {
for(int j = -t; j <= t; j++) { for(int j = -t; j <= t; j++) {
ts.add(getRoutingTile(x31 +i*coordinatesShift, y31 + j*coordinatesShift, 0)); ts.add(getRoutingTile(x31 +i*coordinatesShift, y31 + j*coordinatesShift, 0));
@ -434,9 +433,6 @@ public class RoutingContext {
excludeDuplications.clear(); excludeDuplications.clear();
} }
} }
if (calculationProgress != null) {
calculationProgress.timeToFindInitialSegments += (System.nanoTime() - now);
}
} }
@SuppressWarnings("unused") @SuppressWarnings("unused")