Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3166)

Unified Diff: runtime/observatory/tests/service/get_vm_timeline_rpc_test.dart

Issue 1533323004: Support narrowing a timeline to a given time window (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/lib/timeline.cc ('k') | runtime/vm/profiler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/observatory/tests/service/get_vm_timeline_rpc_test.dart
diff --git a/runtime/observatory/tests/service/get_vm_timeline_rpc_test.dart b/runtime/observatory/tests/service/get_vm_timeline_rpc_test.dart
index 3de30cb20b3dfe011d86602586859a56f634986c..63277b7e7fd567a211d11582b7392d1ad34f22b9 100644
--- a/runtime/observatory/tests/service/get_vm_timeline_rpc_test.dart
+++ b/runtime/observatory/tests/service/get_vm_timeline_rpc_test.dart
@@ -32,6 +32,35 @@ bool eventsContains(List<Map> events, String phase, String name) {
return false;
}
+int timeOrigin(List<Map> events) {
+ if (events.length == 0) {
+ return 0;
+ }
+ int smallest = events[0]['ts'];
+ for (var i = 0; i < events.length; i++) {
+ Map event = events[i];
+ if (event['ts'] < smallest) {
+ smallest = event['ts'];
+ }
+ }
+ return smallest;
+}
+
+int timeDuration(List<Map> events, int timeOrigin) {
+ if (events.length == 0) {
+ return 0;
+ }
+ int biggestDuration = events[0]['ts'] - timeOrigin;
+ for (var i = 0; i < events.length; i++) {
+ Map event = events[i];
+ int duration = event['ts'] - timeOrigin;
+ if (duration > biggestDuration) {
+ biggestDuration = duration;
+ }
+ }
+ return biggestDuration;
+}
+
void allEventsHaveIsolateNumber(List<Map> events) {
for (Map event in events) {
if (event['ph'] == 'M') {
@@ -61,6 +90,7 @@ var tests = [
Map result = await vm.invokeRpcNoUpgrade('_getVMTimeline', {});
expect(result['type'], equals('_Timeline'));
expect(result['traceEvents'], new isInstanceOf<List>());
+ final int numEvents = result['traceEvents'].length;
List<Map> dartEvents = filterForDartEvents(result['traceEvents']);
expect(dartEvents.length, equals(5));
allEventsHaveIsolateNumber(dartEvents);
@@ -71,6 +101,19 @@ var tests = [
expect(eventsContains(dartEvents, 'e', 'TASK1'), isTrue);
expect(eventsContains(dartEvents, 'n', 'ITASK'), isTrue);
expect(eventsContains(dartEvents, 'q', 'ITASK'), isFalse);
+ // Calculate the time Window of Dart events.
+ int origin = timeOrigin(dartEvents);
+ int extent = timeDuration(dartEvents, origin);
+ // Query for the timeline with the time window for Dart events.
+ result = await vm.invokeRpcNoUpgrade('_getVMTimeline', {
+ 'timeOriginMicros': origin,
+ 'timeExtentMicros': extent
+ });
+ // Verify that we received fewer events than before.
+ expect(result['traceEvents'].length, lessThan(numEvents));
+ // Verify that we have the same number of Dart events.
+ List<Map> dartEvents2 = filterForDartEvents(result['traceEvents']);
+ expect(dartEvents2.length, dartEvents.length);
},
];
« no previous file with comments | « runtime/lib/timeline.cc ('k') | runtime/vm/profiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698