VmService timestamp does not correspond to the flutter driver timeline event timestamp

69 Views Asked by At

I have dart test where I do

setUp() async {
  vm_service.VmService vms = await vmServiceConnectUri(vmUrl);
  vmsStartTime = (await vms.getVMTimelineMicros()).timestamp;
  await flutterDriver.startTracing()
}
tearDown() async {
  vmsEndTime = (await vms.getVMTimelineMicros()).timestamp;
  Timeline timeline = await driver.stopTracingAndDownloadTimeline();
}

Tests run for around 30 seconds each. And for some reason after the tests I have something like

vmsStartTime = 4323069605
vmsEndTime =   4323088753

In timeline first event timestampMicros is

"ts":                      4318344424

Also:

"timeOriginMicros": 4318344424,
"timeExtentMicros": 2080190

I use vmsStartTest and vmsEndTest to filter out events related to each tests and with such issues I miss all the events related to the test from the timeline. Please help me to understand why that happens and how to deal with it?

1

There are 1 best solutions below

0
On

For now using traceAction seems to give the best results. So each action I do during the test is a subject for traceAction. Timeline from each next traceAction is appended to global timeline json object (events are appended and duration is calculated as customTimelineJson["timeExtentMicros"] = timeline.json["timeOriginMicros"] + timeline.json["timeExtentMicros"] - customTimelineJson["timeOriginMicros"]; This helps to keep most of the events in the timeline. Test start time is mapped to the timestampMicros of the first event in the very first event in timeline. Test end is taken from the last event in the last timeline of the last traceAction. timeOriginMicros is taken from the first event of the very first traceAction timeline