You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2021/12/30 04:57:52 UTC

[GitHub] [beam] KonradJanica commented on a change in pull request #16363: [BEAM-13557] [Playground] show code execution time

KonradJanica commented on a change in pull request #16363:
URL: https://github.com/apache/beam/pull/16363#discussion_r776561808



##########
File path: playground/frontend/lib/pages/playground/states/playground_state.dart
##########
@@ -156,6 +166,39 @@ class PlaygroundState with ChangeNotifier {
       status: RunCodeStatus.finished,
       output: _selectedExample!.outputs,
     );
+    _executionTime?.close();
     notifyListeners();
   }
+
+  StreamController<int> _createExecutionTimeStream() {
+    StreamController<int>? streamController;
+    Timer? timer;
+    Duration timerInterval = const Duration(milliseconds: kExecutionTimeUpdate);
+    int ms = 0;
+
+    void stopTimer() {
+      if (timer != null) {
+        timer?.cancel();

Review comment:
       Redundant question mark or null check.

##########
File path: playground/frontend/lib/pages/playground/states/playground_state.dart
##########
@@ -121,6 +128,7 @@ class PlaygroundState with ChangeNotifier {
       notifyListeners();
       return;
     }
+    _executionTime = _createExecutionTimeStream();

Review comment:
       Perhaps add `_executionTime?.close()` above this line to prevent a memory leak. I'm concerned about the circular reference inside the `stopTimer` and `tick` methods. Normally circular references are fine in JavaScript, but in this case, the setTimeout loop might cause issues.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org