@@ -14,11 +14,11 @@ class TimelineRepositoryBase {
14
14
static const kTimeOriginMicros = 'timeOriginMicros' ;
15
15
static const kTimeExtentMicros = 'timeExtentMicros' ;
16
16
17
- Future <void > _formatSamples (
18
- M . Isolate isolate, Map traceObject, S . ServiceMap cpuSamples) async {
17
+ Future <void > _formatSamples (M . Isolate isolate, Map traceObject,
18
+ Future < S . ServiceObject > cpuSamples) async {
19
19
const kRootFrameId = 0 ;
20
20
final profile = SampleProfile ();
21
- await profile.load (isolate as S .ServiceObjectOwner , cpuSamples);
21
+ await profile.load (isolate as S .ServiceObjectOwner , await cpuSamples);
22
22
final trie = profile.loadFunctionTree (M .ProfileTreeDirection .inclusive);
23
23
final root = trie.root;
24
24
int nextId = kRootFrameId;
@@ -66,24 +66,20 @@ class TimelineRepositoryBase {
66
66
Future <Map > getCpuProfileTimeline (M .VMRef ref,
67
67
{int timeOriginMicros, int timeExtentMicros}) async {
68
68
final S .VM vm = ref as S .VM ;
69
- final sampleRequests = < Future > [];
69
+ final traceObject = < String , dynamic > {
70
+ _kStackFrames: {},
71
+ _kTraceEvents: [],
72
+ };
70
73
71
- for ( final isolate in vm.isolates) {
72
- sampleRequests. add ( vm.invokeRpc ('getCpuSamples' , {
74
+ await Future . wait ( vm.isolates. map ((isolate ) {
75
+ final samples = vm.invokeRpc ('getCpuSamples' , {
73
76
'isolateId' : isolate.id,
74
77
if (timeOriginMicros != null ) kTimeOriginMicros: timeOriginMicros,
75
78
if (timeExtentMicros != null ) kTimeExtentMicros: timeExtentMicros,
76
- }));
77
- }
79
+ });
80
+ return _formatSamples (isolate, traceObject, samples);
81
+ }));
78
82
79
- final completed = await Future .wait (sampleRequests);
80
- final traceObject = < String , dynamic > {
81
- _kStackFrames: {},
82
- _kTraceEvents: [],
83
- };
84
- for (int i = 0 ; i < vm.isolates.length; ++ i) {
85
- await _formatSamples (vm.isolates[i], traceObject, completed[i]);
86
- }
87
83
return traceObject;
88
84
}
89
85
0 commit comments