|
MATSIM
|
Public Member Functions | |
| IterationStopWatch () | |
| void | reset () |
| void | beginIteration (final int iteration) |
| void | beginOperation (final String identifier) |
| void | endOperation (final String identifier) |
| void | endIteration () |
| void | timestamp (final String identifier) |
| void | writeSeparatedFile (final String filename, final String delimiter) |
| void | writeGraphFile (String filename) |
Static Public Attributes | |
| static final String | OPERATION_ITERATION = "iteration" |
| static final String | OPERATION_OTHER = "other" |
Private Member Functions | |
| void | ensureIdentifier (final String identifier) |
| void | ensureOperation (final String identifier) |
| String | formatMilliTime (final Long millis) |
Private Attributes | |
| Integer | iteration = null |
| final Map< Integer, Map< String, Long > > | iterations |
| final List< String > | identifiers |
| final List< String > | operations |
| Map< String, Long > | currentIterationValues |
| int | nextIdentifierPosition = 0 |
| int | nextOperationPosition = 0 |
| final DateFormat | formatter = new SimpleDateFormat("HH:mm:ss") |
| Stack< String > | currentMeasuredOperations |
| Map< String, List< String > > | currentIterationChildren |
| final Map< Integer, Map< String, List< String > > > | children |
This class provides a mechanism similar to a stop watch, allowing to measure the duration of operations and remembering time stamps. The class collects all the data and provides a simple analysis of the time stamps and durations for operations for each iteration in the simulation. This analysis can be dumped to console or to a file using the write()-methods.
Definition at line 43 of file IterationStopWatch.java.
| org.matsim.analysis.IterationStopWatch.IterationStopWatch | ( | ) |
Creates a new IterationStopWatch.
Definition at line 84 of file IterationStopWatch.java.
| void org.matsim.analysis.IterationStopWatch.reset | ( | ) |
Resets the stop watch, deleting all gathered values.
Definition at line 95 of file IterationStopWatch.java.
| void org.matsim.analysis.IterationStopWatch.beginIteration | ( | final int | iteration | ) |
Sets the current iteration, so that the times measured using beginOperation(String), endOperation(String) and timestamp(String) are assigned to the correct iteration for the analysis.
Definition at line 113 of file IterationStopWatch.java.
References org.matsim.analysis.IterationStopWatch.beginOperation(), and org.matsim.analysis.IterationStopWatch.iteration.

| void org.matsim.analysis.IterationStopWatch.beginOperation | ( | final String | identifier | ) |
Tells the stop watch that an operation begins.
| identifier | The name of the beginning operation. |
Definition at line 132 of file IterationStopWatch.java.
Referenced by org.matsim.analysis.IterationStopWatch.beginIteration().
| void org.matsim.analysis.IterationStopWatch.endOperation | ( | final String | identifier | ) |
Tells the stop watch that an operation ends. The operation must have been started before with beginOperation(String).
| identifier | The name of the ending operation. |
Definition at line 160 of file IterationStopWatch.java.
References org.matsim.analysis.IterationStopWatch.ensureIdentifier(), and org.matsim.analysis.IterationStopWatch.ensureOperation().
Referenced by org.matsim.analysis.IterationStopWatch.endIteration().

| void org.matsim.analysis.IterationStopWatch.endIteration | ( | ) |
Definition at line 170 of file IterationStopWatch.java.
References org.matsim.analysis.IterationStopWatch.endOperation().

| void org.matsim.analysis.IterationStopWatch.timestamp | ( | final String | identifier | ) |
Tells the stop watch that a special event happened, for which the time should be remembered.
| identifier | The name of the event. |
Definition at line 179 of file IterationStopWatch.java.
References org.matsim.analysis.IterationStopWatch.ensureIdentifier().

| void org.matsim.analysis.IterationStopWatch.writeSeparatedFile | ( | final String | filename, |
| final String | delimiter | ||
| ) |
Writes the gathered data into a file.
| filename | The name of a file where to write the gathered data. |
| delimiter | The delimiter to be used as field separator. |
Definition at line 190 of file IterationStopWatch.java.
References org.matsim.analysis.IterationStopWatch.formatMilliTime(), org.matsim.core.utils.io.IOUtils.getBufferedWriter(), and org.matsim.core.utils.misc.Time.writeTime().

| void org.matsim.analysis.IterationStopWatch.writeGraphFile | ( | String | filename | ) |
Writes the gathered data as graph into a png file.
| filename | The name of a file where to write the gathered data. |
Definition at line 245 of file IterationStopWatch.java.
References org.matsim.core.utils.charts.ChartUtil.addMatsimLogo(), org.matsim.core.utils.charts.StackedBarChart.addSeries(), org.matsim.core.utils.charts.StackedBarChart.getChart(), org.matsim.analysis.IterationStopWatch.iterations, and org.matsim.core.utils.charts.ChartUtil.saveAsPng().

|
private |
Make sure the given identifier exists in our collection. If it is missing, insert it at the correct place. "Correct" means that it tries to insert this identifier right after the last-requested identifier. This should help to write the gathered data out in a natural way.
Definition at line 325 of file IterationStopWatch.java.
Referenced by org.matsim.analysis.IterationStopWatch.endOperation(), and org.matsim.analysis.IterationStopWatch.timestamp().
|
private |
Does the same as ensureIdentifier(String), but for operation-identifiers.
Definition at line 338 of file IterationStopWatch.java.
Referenced by org.matsim.analysis.IterationStopWatch.endOperation().
|
private |
Formats the time given in milliseconds (e.g. returned by java.lang.System#currentTimeMillis()) nicely for output.
| millis | A time value in milliseconds |
millis is null Definition at line 355 of file IterationStopWatch.java.
Referenced by org.matsim.analysis.IterationStopWatch.writeSeparatedFile().
|
static |
Strings used to identify the operations in the IterationStopWatch.
Definition at line 47 of file IterationStopWatch.java.
|
static |
Definition at line 52 of file IterationStopWatch.java.
|
private |
The current iteration number, or null if not yet initialized.
Definition at line 55 of file IterationStopWatch.java.
Referenced by org.matsim.analysis.IterationStopWatch.beginIteration().
|
private |
The main collection, where all the gathered data is stored.
Definition at line 58 of file IterationStopWatch.java.
Referenced by org.matsim.analysis.IterationStopWatch.writeGraphFile().
|
private |
A list of identifiers used to enumerate time stamps.
Definition at line 61 of file IterationStopWatch.java.
|
private |
A list of identifiers used to enumerate operations.
Definition at line 64 of file IterationStopWatch.java.
|
private |
A cache for easy access to the current object in iterations.
Definition at line 67 of file IterationStopWatch.java.
|
private |
The position within identifiers, where the next identifier is expected.
Definition at line 70 of file IterationStopWatch.java.
|
private |
The position within operations, where the next identifier is expected.
Definition at line 73 of file IterationStopWatch.java.
|
private |
A formatter for dates, used when writing out the data.
Definition at line 76 of file IterationStopWatch.java.
|
private |
data structures to identify nested operations
Definition at line 79 of file IterationStopWatch.java.
|
private |
Definition at line 80 of file IterationStopWatch.java.
|
private |
Definition at line 81 of file IterationStopWatch.java.
1.8.13