forked from HSLdevcom/OpenTripPlanner
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from ibi-group/graph-builder-improvements
Graph builder improvements
- Loading branch information
Showing
43 changed files
with
353 additions
and
1,215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/org/opentripplanner/graph_builder/module/GraphBuilderModuleSummary.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.opentripplanner.graph_builder.module; | ||
|
||
import org.opentripplanner.graph_builder.services.GraphBuilderModule; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Used to store statistics about various how various graph build modules performed. | ||
*/ | ||
public class GraphBuilderModuleSummary extends GraphBuilderSummary { | ||
private List<GraphBuilderTaskSummary> subTasks = new ArrayList<>(); | ||
|
||
public GraphBuilderModuleSummary(GraphBuilderModule module) { | ||
this.name = module.getClass().getSimpleName(); | ||
} | ||
|
||
@Override | ||
public String getLogDisplayName() { | ||
return String.format("graph builder module: %s", name); | ||
} | ||
|
||
public GraphBuilderTaskSummary addSubTask(String name) { | ||
GraphBuilderTaskSummary subTask = new GraphBuilderTaskSummary(this, name); | ||
subTasks.add(subTask); | ||
return subTask; | ||
} | ||
|
||
public List<GraphBuilderTaskSummary> getSubTasks() { | ||
return subTasks; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/org/opentripplanner/graph_builder/module/GraphBuilderSummary.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.opentripplanner.graph_builder.module; | ||
|
||
public abstract class GraphBuilderSummary { | ||
private long endTime; | ||
protected String name; | ||
private long startTime = 0; | ||
|
||
public long getDuration() { | ||
return endTime - startTime; | ||
} | ||
|
||
public String getName() { return name; } | ||
|
||
public abstract String getLogDisplayName(); | ||
|
||
public String finish() { | ||
if (this.startTime == 0) { | ||
throw new IllegalStateException("GraphBuilderSummary instance finished before it was started!"); | ||
} | ||
this.endTime = System.currentTimeMillis(); | ||
return String.format( | ||
"Finished %s in %.1f seconds", | ||
getLogDisplayName(), | ||
getDuration() / 1000.0 | ||
); | ||
} | ||
|
||
public String start() { | ||
if (this.startTime != 0) { | ||
throw new IllegalStateException("GraphBuilderSummary instance has already been started!"); | ||
} | ||
this.startTime = System.currentTimeMillis(); | ||
return String.format("Starting %s", getLogDisplayName()); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/org/opentripplanner/graph_builder/module/GraphBuilderTaskSummary.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.opentripplanner.graph_builder.module; | ||
|
||
public class GraphBuilderTaskSummary extends GraphBuilderSummary { | ||
private final GraphBuilderModuleSummary parentModuleSummary; | ||
|
||
public GraphBuilderTaskSummary(GraphBuilderModuleSummary graphBuilderModuleSummary, String name) { | ||
this.name = name; | ||
this.parentModuleSummary = graphBuilderModuleSummary; | ||
} | ||
|
||
@Override | ||
public String getLogDisplayName() { | ||
return String.format("%s subtask: %s", parentModuleSummary.getLogDisplayName(), name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.