{"action":"created","comment":{"url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/comments/70173537","id":70173537,"diff_hunk":"@@ -0,0 +1,164 @@\n+package edu.wpi.grip.ui.analysis;\n+\n+import edu.wpi.grip.core.Step;\n+import edu.wpi.grip.core.events.BenchmarkEvent;\n+import edu.wpi.grip.core.events.RunStoppedEvent;\n+import edu.wpi.grip.core.events.StepRemovedEvent;\n+import edu.wpi.grip.core.events.TimerEvent;\n+import edu.wpi.grip.core.metrics.Analysis;\n+import edu.wpi.grip.core.metrics.BenchmarkRunner;\n+import edu.wpi.grip.core.metrics.HotnessCalculator;\n+import edu.wpi.grip.core.metrics.Statistics;\n+\n+import com.google.common.eventbus.Subscribe;\n+\n+import org.apache.commons.lang3.tuple.Pair;\n+\n+import java.util.ArrayList;\n+import java.util.List;\n+\n+import javafx.beans.property.SimpleObjectProperty;\n+import javafx.beans.property.SimpleStringProperty;\n+import javafx.collections.FXCollections;\n+import javafx.collections.ObservableList;\n+import javafx.fxml.FXML;\n+import javafx.geometry.Insets;\n+import javafx.scene.control.Button;\n+import javafx.scene.control.Label;\n+import javafx.scene.control.ProgressBar;\n+import javafx.scene.control.TableColumn;\n+import javafx.scene.control.TableView;\n+import javafx.scene.control.TextField;\n+import javafx.scene.layout.HBox;\n+\n+import javax.annotation.Nullable;\n+\n+import static com.google.common.base.Preconditions.checkNotNull;\n+\n+/**\n+ * Controller for the analysis window.\n+ */\n+public class AnalysisWindowController {\n+  // Table\n+  @FXML\n+  private TableView<Pair<Step, Analysis>> table;\n+  @FXML\n+  private TableColumn<Pair<Step, Analysis>, String> operationColumn;\n+  @FXML\n+  private TableColumn<Pair<Step, Analysis>, TimeView> timeColumn;\n+\n+  // Benchmarking\n+  @FXML\n+  private Button benchmarkButton;\n+  @FXML\n+  private TextField benchmarkRunsField;\n+  private BenchmarkRunner benchmarker;\n+\n+  private List<Pair<Step, Analysis>> stepData = new ArrayList<>();\n+  private ObservableList<Pair<Step, Analysis>> tableItems = FXCollections.observableArrayList();\n+\n+  private final HotnessCalculator hotnessCalculator = new HotnessCalculator();\n+  private final Analysis analysis = new Analysis();\n+  private Statistics lastStats;\n+\n+  /**\n+   * Initializes the controller. This should only be called by the FXML loader.\n+   */\n+  public void initialize() {\n+    table.setPlaceholder(new Label(\"Waiting for steps\"));\n+    operationColumn.prefWidthProperty().bind(table.widthProperty().multiply(0.499));\n+    timeColumn.prefWidthProperty().bind(table.widthProperty().multiply(0.499));\n+    operationColumn.setCellValueFactory(\n+        e -> new SimpleStringProperty(e.getValue().getKey().getOperationDescription().name()));\n+    timeColumn.setCellValueFactory(\n+        e -> {\n+          Analysis a = e.getValue().getValue();\n+          final double avg = a.getAverage();\n+          return new SimpleObjectProperty<>(\n+              new TimeView(avg, avg / lastStats.getSum(), hotnessCalculator.hotness(lastStats, avg))\n+          );\n+        });\n+    table.setItems(tableItems);\n+\n+    benchmarkRunsField.textProperty().addListener((observable, oldValue, newValue) -> {\n+      if ((oldValue.isEmpty() && newValue.equals(\"0\")) || !newValue.matches(\"[\\\\d]*\")) {\n+        benchmarkRunsField.setText(oldValue);\n+        return;\n+      }\n+      benchmarkButton.setDisable(newValue.isEmpty());\n+    });\n+  }\n+\n+  @Subscribe\n+  private void onRun(TimerEvent<?> event) {\n+    if (event.getSource() instanceof Step) {\n+      Step source = (Step) event.getSource();\n+      stepData.add(Pair.of(source, event.getData()));\n+      analysis.add(event.getData().getAverage());\n+    }\n+  }\n+\n+  @Subscribe\n+  private void onStepRemoved(StepRemovedEvent event) {\n+    stepData.stream()\n+        .filter(p -> p.getLeft() == event.getStep()) // Want reference equality\n+        .findAny()\n+        .ifPresent(stepData::remove);\n+    analysis.reset();\n+  }\n+\n+  @Subscribe\n+  private void onPipelineFinish(@Nullable RunStoppedEvent event) {\n+    // Update the table after the pipeline finishes\n+    tableItems.clear();\n+    tableItems.addAll(stepData);\n+    lastStats = analysis.getStatistics();\n+    // Reset for the next run\n+    stepData.clear();\n+    analysis.reset();\n+  }\n+\n+  @Subscribe\n+  private void onBenchmark(BenchmarkEvent event) {\n+    benchmarkButton.setDisable(event.isStart());\n+    benchmarkRunsField.setDisable(event.isStart());\n+  }\n+\n+  public void setBenchmarker(BenchmarkRunner benchmarker) {\n+    this.benchmarker = checkNotNull(benchmarker, \"benchmarker\");\n+  }\n+\n+  @FXML\n+  private void runBenchmark() {","path":"ui/src/main/java/edu/wpi/grip/ui/analysis/AnalysisWindowController.java","position":132,"original_position":132,"commit_id":"0a53a78612db65ac71e2ab041dd010b885bd0b4c","original_commit_id":"0a53a78612db65ac71e2ab041dd010b885bd0b4c","user":{"login":"codacy-bot","id":19940114,"avatar_url":"https://avatars.githubusercontent.com/u/19940114?v=3","gravatar_id":"","url":"https://api.github.com/users/codacy-bot","html_url":"https://github.com/codacy-bot","followers_url":"https://api.github.com/users/codacy-bot/followers","following_url":"https://api.github.com/users/codacy-bot/following{/other_user}","gists_url":"https://api.github.com/users/codacy-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/codacy-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codacy-bot/subscriptions","organizations_url":"https://api.github.com/users/codacy-bot/orgs","repos_url":"https://api.github.com/users/codacy-bot/repos","events_url":"https://api.github.com/users/codacy-bot/events{/privacy}","received_events_url":"https://api.github.com/users/codacy-bot/received_events","type":"User","site_admin":false},"body":"![Codacy](https://www.codacy.com/assets/images/favicon.png) Issue found: [Avoid unused private methods such as 'runBenchmark()'.](https://www.codacy.com/app/WPIRoboticsProjects/GRIP/file/2949010397/issues/source?bid=2943107&fileBranchId=3413130#l132)","created_at":"2016-07-09T23:24:20Z","updated_at":"2016-07-09T23:24:20Z","html_url":"https://github.com/WPIRoboticsProjects/GRIP/pull/613#discussion_r70173537","pull_request_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/613","_links":{"self":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/comments/70173537"},"html":{"href":"https://github.com/WPIRoboticsProjects/GRIP/pull/613#discussion_r70173537"},"pull_request":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/613"}}},"pull_request":{"url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/613","id":76615678,"html_url":"https://github.com/WPIRoboticsProjects/GRIP/pull/613","diff_url":"https://github.com/WPIRoboticsProjects/GRIP/pull/613.diff","patch_url":"https://github.com/WPIRoboticsProjects/GRIP/pull/613.patch","issue_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues/613","number":613,"state":"open","locked":false,"title":"Add support for timing steps and pipelines","user":{"login":"SamCarlberg","id":6320992,"avatar_url":"https://avatars.githubusercontent.com/u/6320992?v=3","gravatar_id":"","url":"https://api.github.com/users/SamCarlberg","html_url":"https://github.com/SamCarlberg","followers_url":"https://api.github.com/users/SamCarlberg/followers","following_url":"https://api.github.com/users/SamCarlberg/following{/other_user}","gists_url":"https://api.github.com/users/SamCarlberg/gists{/gist_id}","starred_url":"https://api.github.com/users/SamCarlberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SamCarlberg/subscriptions","organizations_url":"https://api.github.com/users/SamCarlberg/orgs","repos_url":"https://api.github.com/users/SamCarlberg/repos","events_url":"https://api.github.com/users/SamCarlberg/events{/privacy}","received_events_url":"https://api.github.com/users/SamCarlberg/received_events","type":"User","site_admin":false},"body":"This lets users know which parts of their pipelines take the most time, and how long the pipeline takes as a whole.\r\n\r\n![Sample pipeline](https://cloud.githubusercontent.com/assets/6320992/16660803/e9722c18-443d-11e6-8e1f-9a0fb24a2c9a.png)","created_at":"2016-07-07T15:28:59Z","updated_at":"2016-07-09T23:24:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6a567ab290ae0c5593c13f9996207672737906a0","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/613/commits","review_comments_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/613/comments","review_comment_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/comments{/number}","comments_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues/613/comments","statuses_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/statuses/0a53a78612db65ac71e2ab041dd010b885bd0b4c","head":{"label":"SamCarlberg:feat/timing","ref":"feat/timing","sha":"0a53a78612db65ac71e2ab041dd010b885bd0b4c","user":{"login":"SamCarlberg","id":6320992,"avatar_url":"https://avatars.githubusercontent.com/u/6320992?v=3","gravatar_id":"","url":"https://api.github.com/users/SamCarlberg","html_url":"https://github.com/SamCarlberg","followers_url":"https://api.github.com/users/SamCarlberg/followers","following_url":"https://api.github.com/users/SamCarlberg/following{/other_user}","gists_url":"https://api.github.com/users/SamCarlberg/gists{/gist_id}","starred_url":"https://api.github.com/users/SamCarlberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SamCarlberg/subscriptions","organizations_url":"https://api.github.com/users/SamCarlberg/orgs","repos_url":"https://api.github.com/users/SamCarlberg/repos","events_url":"https://api.github.com/users/SamCarlberg/events{/privacy}","received_events_url":"https://api.github.com/users/SamCarlberg/received_events","type":"User","site_admin":false},"repo":{"id":54142171,"name":"GRIP","full_name":"SamCarlberg/GRIP","owner":{"login":"SamCarlberg","id":6320992,"avatar_url":"https://avatars.githubusercontent.com/u/6320992?v=3","gravatar_id":"","url":"https://api.github.com/users/SamCarlberg","html_url":"https://github.com/SamCarlberg","followers_url":"https://api.github.com/users/SamCarlberg/followers","following_url":"https://api.github.com/users/SamCarlberg/following{/other_user}","gists_url":"https://api.github.com/users/SamCarlberg/gists{/gist_id}","starred_url":"https://api.github.com/users/SamCarlberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SamCarlberg/subscriptions","organizations_url":"https://api.github.com/users/SamCarlberg/orgs","repos_url":"https://api.github.com/users/SamCarlberg/repos","events_url":"https://api.github.com/users/SamCarlberg/events{/privacy}","received_events_url":"https://api.github.com/users/SamCarlberg/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/SamCarlberg/GRIP","description":"Program for rapidly developing computer vision applications","fork":true,"url":"https://api.github.com/repos/SamCarlberg/GRIP","forks_url":"https://api.github.com/repos/SamCarlberg/GRIP/forks","keys_url":"https://api.github.com/repos/SamCarlberg/GRIP/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SamCarlberg/GRIP/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SamCarlberg/GRIP/teams","hooks_url":"https://api.github.com/repos/SamCarlberg/GRIP/hooks","issue_events_url":"https://api.github.com/repos/SamCarlberg/GRIP/issues/events{/number}","events_url":"https://api.github.com/repos/SamCarlberg/GRIP/events","assignees_url":"https://api.github.com/repos/SamCarlberg/GRIP/assignees{/user}","branches_url":"https://api.github.com/repos/SamCarlberg/GRIP/branches{/branch}","tags_url":"https://api.github.com/repos/SamCarlberg/GRIP/tags","blobs_url":"https://api.github.com/repos/SamCarlberg/GRIP/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SamCarlberg/GRIP/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SamCarlberg/GRIP/git/refs{/sha}","trees_url":"https://api.github.com/repos/SamCarlberg/GRIP/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SamCarlberg/GRIP/statuses/{sha}","languages_url":"https://api.github.com/repos/SamCarlberg/GRIP/languages","stargazers_url":"https://api.github.com/repos/SamCarlberg/GRIP/stargazers","contributors_url":"https://api.github.com/repos/SamCarlberg/GRIP/contributors","subscribers_url":"https://api.github.com/repos/SamCarlberg/GRIP/subscribers","subscription_url":"https://api.github.com/repos/SamCarlberg/GRIP/subscription","commits_url":"https://api.github.com/repos/SamCarlberg/GRIP/commits{/sha}","git_commits_url":"https://api.github.com/repos/SamCarlberg/GRIP/git/commits{/sha}","comments_url":"https://api.github.com/repos/SamCarlberg/GRIP/comments{/number}","issue_comment_url":"https://api.github.com/repos/SamCarlberg/GRIP/issues/comments{/number}","contents_url":"https://api.github.com/repos/SamCarlberg/GRIP/contents/{+path}","compare_url":"https://api.github.com/repos/SamCarlberg/GRIP/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SamCarlberg/GRIP/merges","archive_url":"https://api.github.com/repos/SamCarlberg/GRIP/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SamCarlberg/GRIP/downloads","issues_url":"https://api.github.com/repos/SamCarlberg/GRIP/issues{/number}","pulls_url":"https://api.github.com/repos/SamCarlberg/GRIP/pulls{/number}","milestones_url":"https://api.github.com/repos/SamCarlberg/GRIP/milestones{/number}","notifications_url":"https://api.github.com/repos/SamCarlberg/GRIP/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SamCarlberg/GRIP/labels{/name}","releases_url":"https://api.github.com/repos/SamCarlberg/GRIP/releases{/id}","deployments_url":"https://api.github.com/repos/SamCarlberg/GRIP/deployments","created_at":"2016-03-17T18:30:55Z","updated_at":"2016-03-17T18:30:56Z","pushed_at":"2016-07-09T23:21:26Z","git_url":"git://github.com/SamCarlberg/GRIP.git","ssh_url":"git@github.com:SamCarlberg/GRIP.git","clone_url":"https://github.com/SamCarlberg/GRIP.git","svn_url":"https://github.com/SamCarlberg/GRIP","homepage":"http://wpiroboticsprojects.github.io/GRIP","size":41261,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"WPIRoboticsProjects:master","ref":"master","sha":"9ce19be173c7c3ce368493939ecff6a64204e595","user":{"login":"WPIRoboticsProjects","id":14004340,"avatar_url":"https://avatars.githubusercontent.com/u/14004340?v=3","gravatar_id":"","url":"https://api.github.com/users/WPIRoboticsProjects","html_url":"https://github.com/WPIRoboticsProjects","followers_url":"https://api.github.com/users/WPIRoboticsProjects/followers","following_url":"https://api.github.com/users/WPIRoboticsProjects/following{/other_user}","gists_url":"https://api.github.com/users/WPIRoboticsProjects/gists{/gist_id}","starred_url":"https://api.github.com/users/WPIRoboticsProjects/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WPIRoboticsProjects/subscriptions","organizations_url":"https://api.github.com/users/WPIRoboticsProjects/orgs","repos_url":"https://api.github.com/users/WPIRoboticsProjects/repos","events_url":"https://api.github.com/users/WPIRoboticsProjects/events{/privacy}","received_events_url":"https://api.github.com/users/WPIRoboticsProjects/received_events","type":"Organization","site_admin":false},"repo":{"id":41505521,"name":"GRIP","full_name":"WPIRoboticsProjects/GRIP","owner":{"login":"WPIRoboticsProjects","id":14004340,"avatar_url":"https://avatars.githubusercontent.com/u/14004340?v=3","gravatar_id":"","url":"https://api.github.com/users/WPIRoboticsProjects","html_url":"https://github.com/WPIRoboticsProjects","followers_url":"https://api.github.com/users/WPIRoboticsProjects/followers","following_url":"https://api.github.com/users/WPIRoboticsProjects/following{/other_user}","gists_url":"https://api.github.com/users/WPIRoboticsProjects/gists{/gist_id}","starred_url":"https://api.github.com/users/WPIRoboticsProjects/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WPIRoboticsProjects/subscriptions","organizations_url":"https://api.github.com/users/WPIRoboticsProjects/orgs","repos_url":"https://api.github.com/users/WPIRoboticsProjects/repos","events_url":"https://api.github.com/users/WPIRoboticsProjects/events{/privacy}","received_events_url":"https://api.github.com/users/WPIRoboticsProjects/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/WPIRoboticsProjects/GRIP","description":"Program for rapidly developing computer vision applications","fork":false,"url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP","forks_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/forks","keys_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/keys{/key_id}","collaborators_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/teams","hooks_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/hooks","issue_events_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues/events{/number}","events_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/events","assignees_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/assignees{/user}","branches_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/branches{/branch}","tags_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/tags","blobs_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/git/refs{/sha}","trees_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/git/trees{/sha}","statuses_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/statuses/{sha}","languages_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/languages","stargazers_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/stargazers","contributors_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/contributors","subscribers_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/subscribers","subscription_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/subscription","commits_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/commits{/sha}","git_commits_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/git/commits{/sha}","comments_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/comments{/number}","issue_comment_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues/comments{/number}","contents_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/contents/{+path}","compare_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/compare/{base}...{head}","merges_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/merges","archive_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/downloads","issues_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues{/number}","pulls_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls{/number}","milestones_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/milestones{/number}","notifications_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/labels{/name}","releases_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/releases{/id}","deployments_url":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/deployments","created_at":"2015-08-27T18:59:07Z","updated_at":"2016-06-06T10:25:39Z","pushed_at":"2016-07-09T23:21:27Z","git_url":"git://github.com/WPIRoboticsProjects/GRIP.git","ssh_url":"git@github.com:WPIRoboticsProjects/GRIP.git","clone_url":"https://github.com/WPIRoboticsProjects/GRIP.git","svn_url":"https://github.com/WPIRoboticsProjects/GRIP","homepage":"http://wpiroboticsprojects.github.io/GRIP","size":51825,"stargazers_count":105,"watchers_count":105,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":50,"mirror_url":null,"open_issues_count":106,"forks":50,"open_issues":106,"watchers":105,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/613"},"html":{"href":"https://github.com/WPIRoboticsProjects/GRIP/pull/613"},"issue":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues/613"},"comments":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/issues/613/comments"},"review_comments":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/613/comments"},"review_comment":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/pulls/613/commits"},"statuses":{"href":"https://api.github.com/repos/WPIRoboticsProjects/GRIP/statuses/0a53a78612db65ac71e2ab041dd010b885bd0b4c"}}}}
{"actor":{"display_login":"codacy-bot"}}