Skip to content

Commit 2bf2e76

Browse files
author
Brian Vaughn
authored
Add performance marksf or individual fetch() requests (#22176)
1 parent 60a30cf commit 2bf2e76

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

packages/react-devtools-extensions/src/parseHookNames/parseHookNames.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,32 +451,48 @@ function extractAndLoadSourceMaps(
451451
}
452452

453453
function fetchFile(url: string): Promise<string> {
454+
if (__PERFORMANCE_PROFILE__) {
455+
mark('fetchFile("' + url + '")');
456+
}
457+
454458
return new Promise((resolve, reject) => {
455459
fetch(url).then(
456460
response => {
457461
if (response.ok) {
458462
response
459463
.text()
460464
.then(text => {
465+
if (__PERFORMANCE_PROFILE__) {
466+
measure('fetchFile("' + url + '")');
467+
}
461468
resolve(text);
462469
})
463470
.catch(error => {
464471
if (__DEBUG__) {
465472
console.log(`fetchFile() Could not read text for url "${url}"`);
466473
}
474+
if (__PERFORMANCE_PROFILE__) {
475+
measure('fetchFile("' + url + '")');
476+
}
467477
reject(null);
468478
});
469479
} else {
470480
if (__DEBUG__) {
471481
console.log(`fetchFile() Got bad response for url "${url}"`);
472482
}
483+
if (__PERFORMANCE_PROFILE__) {
484+
measure('fetchFile("' + url + '")');
485+
}
473486
reject(null);
474487
}
475488
},
476489
error => {
477490
if (__DEBUG__) {
478491
console.log(`fetchFile() Could not fetch file: ${error.message}`);
479492
}
493+
if (__PERFORMANCE_PROFILE__) {
494+
measure('fetchFile("' + url + '")');
495+
}
480496
reject(null);
481497
},
482498
);

0 commit comments

Comments
 (0)