-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for timing steps and pipelines #613
Merged
SamCarlberg
merged 43 commits into
WPIRoboticsProjects:master
from
SamCarlberg:feat/timing
Oct 31, 2016
Merged
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
3470404
Add support for timing steps and pipelines
SamCarlberg 72a02ee
Suppress PMD warnings
SamCarlberg 0a9302c
Add documentation to StepStarted and StepFinishedEvents
SamCarlberg bbf2379
Add analysis of step timings
SamCarlberg 14911e5
Updated UI test
SamCarlberg 0a53a78
Add benchmarking to analysis window
SamCarlberg b71d79a
Undo accidental formatting
SamCarlberg 493560f
Fix and suppress issues from Codacy
SamCarlberg eed8a26
Add tests for Timer
SamCarlberg 0d8a8a8
Improve UI and increase tolerance for timer tests
SamCarlberg 849ad71
Increase timer test tolerance to 5ms (5%)
SamCarlberg b0dca11
Add tests for BenchmarkRunner
SamCarlberg ca33126
Change analysis averager to a moving average, improve naming and docu…
SamCarlberg 7b8d888
Fix flickering, make Analysis immutable
SamCarlberg f84ae37
Reset timers after running a benchmark.
SamCarlberg 16f3a38
Add tests for MovingAverage
SamCarlberg c79f8c3
Update TimerTest for reset()
SamCarlberg 764cba8
Fix tests (oops)
SamCarlberg 23260d2
Freeze sources while benchmarking
SamCarlberg 9ab9953
Improve Timer API, documentation, and tests
SamCarlberg ba91b1c
Fix accidental formatting (again)
SamCarlberg 39880c0
Merge branch 'master' into feat/timing
SamCarlberg a1ddd49
Remove redundant (ms)
SamCarlberg 9ca431b
Fix PMD issues
SamCarlberg 5d2dce9
Fix PMD in UI
SamCarlberg 7265ddf
Appease Codacy
SamCarlberg 2239269
Merge branch 'master' into feat/timing
SamCarlberg 9be25db
Don't make analysis window block main window. Disable inputs and outp…
SamCarlberg b2db03d
Remove hacky data aggregation from Analysis class.
SamCarlberg 785ff04
Replace custom FixedSizeQueue with guava's EvictingQueue
SamCarlberg 8b7218d
Add option to export results to CSV.
SamCarlberg 5e525ca
Merge branch master into feat/timing
SamCarlberg a513c84
Fix tests
SamCarlberg 9dd68f4
Add tests for metrics
SamCarlberg b2f9d4e
Move CSV to it's own class
SamCarlberg a0aaaeb
Merge master
SamCarlberg 6e06b3b
Fix some checkstyle stuff I missed
SamCarlberg 7c3b79d
Rename Timer.stopped() to stop()
SamCarlberg 3d9f2b6
Delete redudant Analysis class and improve variable names in Statistics
SamCarlberg b01b2b5
Improve Javadoc for statistics hotness function
SamCarlberg b61da85
Fix import order
SamCarlberg 0c3b769
Merge remote-tracking branch 'refs/remotes/WPIRoboicsProjects/master'
SamCarlberg 3d7481c
Move analysis window to fx:include
SamCarlberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
22 changes: 22 additions & 0 deletions
22
core/src/main/java/edu/wpi/grip/core/events/StepFinishedEvent.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,22 @@ | ||
package edu.wpi.grip.core.events; | ||
|
||
import edu.wpi.grip.core.Step; | ||
|
||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
/** | ||
* An event fired when a step has finished running. | ||
*/ | ||
public class StepFinishedEvent { | ||
|
||
private final Step step; | ||
|
||
public StepFinishedEvent(Step step) { | ||
this.step = checkNotNull(step, "step"); | ||
} | ||
|
||
public boolean isRegarding(Step step) { | ||
return this.step.equals(step); | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
core/src/main/java/edu/wpi/grip/core/events/StepStartedEvent.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,23 @@ | ||
package edu.wpi.grip.core.events; | ||
|
||
import edu.wpi.grip.core.Step; | ||
|
||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
/** | ||
* An event fired when a step has started to be run. This will be accompanied by a | ||
* {@link StepFinishedEvent} after the step has finished running. | ||
*/ | ||
public class StepStartedEvent { | ||
|
||
private final Step step; | ||
|
||
public StepStartedEvent(Step step) { | ||
this.step = checkNotNull(step, "step"); | ||
} | ||
|
||
public boolean isRegarding(Step step) { | ||
return this.step.equals(step); | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
|
||
import edu.wpi.grip.core.Pipeline; | ||
import edu.wpi.grip.core.Step; | ||
import edu.wpi.grip.core.events.StepFinishedEvent; | ||
import edu.wpi.grip.core.events.StepStartedEvent; | ||
import edu.wpi.grip.core.sockets.InputSocket; | ||
import edu.wpi.grip.core.sockets.OutputSocket; | ||
import edu.wpi.grip.ui.Controller; | ||
|
@@ -13,13 +15,18 @@ | |
import edu.wpi.grip.ui.util.ControllerMap; | ||
import edu.wpi.grip.ui.util.StyleClassNameUtility; | ||
|
||
import com.google.common.base.Stopwatch; | ||
import com.google.common.eventbus.Subscribe; | ||
import com.google.inject.assistedinject.Assisted; | ||
|
||
import java.io.InputStream; | ||
import java.util.Collection; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import javafx.application.Platform; | ||
import javafx.fxml.FXML; | ||
import javafx.scene.Node; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.control.Labeled; | ||
import javafx.scene.image.Image; | ||
import javafx.scene.image.ImageView; | ||
|
@@ -46,6 +53,8 @@ public class StepController implements Controller { | |
@FXML | ||
private Labeled title; | ||
@FXML | ||
private Label elapsedTime; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can fix it in the fxml with padding |
||
@FXML | ||
private ImageView icon; | ||
@FXML | ||
private HBox buttons; | ||
|
@@ -56,6 +65,8 @@ public class StepController implements Controller { | |
private ControllerMap<InputSocketController, Node> inputSocketMapManager; | ||
private ControllerMap<OutputSocketController, Node> outputSocketMapManager; | ||
|
||
private final Stopwatch stopwatch = Stopwatch.createUnstarted(); | ||
|
||
@Inject | ||
StepController(Pipeline pipeline, | ||
InputSocketControllerFactory inputSocketControllerFactory, | ||
|
@@ -142,6 +153,24 @@ private void moveStepRight() { | |
pipeline.moveStep(step, +1); | ||
} | ||
|
||
@Subscribe | ||
private void started(StepStartedEvent event) { | ||
if (!event.isRegarding(this.step)) { | ||
return; | ||
} | ||
stopwatch.reset().start(); | ||
} | ||
|
||
@Subscribe | ||
private void finished(StepFinishedEvent event) { | ||
if (!event.isRegarding(this.step)) { | ||
return; | ||
} | ||
// Use micros and divide by 1e3 to get decimal points (e.g. 0.3ms instead of 0ms) | ||
final long elapsed = stopwatch.elapsed(TimeUnit.MICROSECONDS); | ||
Platform.runLater(() -> elapsedTime.setText(String.format("Ran in %.1f ms", elapsed / 1e3))); | ||
} | ||
|
||
/** | ||
* Used for assisted injects. Guice will automatically create an instance of this interface so we | ||
* can create step controllers. This lets us use injection with StepController even though it | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This label isn't centered vertically in the status bar, and it separates the start/stop button from the "
Pipeline STATE
" text.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move the Pipeline status into its own label and then center both (i.e. do not use statusBar.setText() for the status)