MCPcopy Create free account
hub / github.com/adobe/react-spectrum / saveTrace

Function saveTrace

perf/runner.mjs:182–205  ·  view source on GitHub ↗
(session, file, operation)

Source from the content-addressed store, hash-verified

180}
181
182async function saveTrace(session, file, operation) {
183 await session.send('Tracing.start', {
184 // toplevel adds task boundaries, so scheduling overhead shows as other work.
185 categories:
186 'toplevel,devtools.timeline,blink.user_timing,disabled-by-default-devtools.timeline.frame',
187 transferMode: 'ReturnAsStream'
188 });
189 await operation();
190 let completed = new Promise(resolve => session.once('Tracing.tracingComplete', resolve));
191 await session.send('Tracing.end');
192 let {stream} = await completed;
193 let output = await fs.open(file, 'w');
194 try {
195 let eof = false;
196 while (!eof) {
197 let chunk = await session.send('IO.read', {handle: stream});
198 await output.write(chunk.base64Encoded ? Buffer.from(chunk.data, 'base64') : chunk.data);
199 eof = chunk.eof;
200 }
201 } finally {
202 await output.close();
203 await session.send('IO.close', {handle: stream});
204 }
205}
206
207// Base and candidate pages stay open side by side, and their trials alternate in
208// ABBA order so drift within a launch affects both arms alike. `onTrial` reports the

Callers 1

diagnoseFunction · 0.85

Calls 2

openMethod · 0.65
closeMethod · 0.65

Tested by

no test coverage detected