Skip to content

Commit ffdba4a

Browse files
committed
Nicer import of chrome-trace profiles generated by gradle-profiler.
1 parent 7f30744 commit ffdba4a

2 files changed

Lines changed: 183 additions & 12 deletions

File tree

src/profile-logic/import/chrome.js

Lines changed: 75 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,21 @@ function extractMarkers(
951951
},
952952
],
953953
},
954+
{
955+
name: 'Text',
956+
tooltipLabel: '{marker.name}',
957+
tableLabel: '{marker.name} — {marker.data.text}',
958+
chartLabel: '{marker.data.text}',
959+
display: ['marker-chart', 'marker-table'],
960+
data: [
961+
{
962+
key: 'text',
963+
label: 'Description',
964+
format: 'string',
965+
searchable: true,
966+
},
967+
],
968+
},
954969
];
955970

956971
for (const [name, events] of eventsByName.entries()) {
@@ -1005,21 +1020,69 @@ function extractMarkers(
10051020
if (event.args && typeof event.args === 'object') {
10061021
argData = (event.args: any).data || null;
10071022
}
1008-
markers.name.push(stringTable.indexForString(name));
1023+
10091024
markers.category.push(otherCategoryIndex);
1025+
let newData = {};
1026+
const prefixes = [
1027+
'Apply build file',
1028+
'Apply initialization script',
1029+
'Apply plugin',
1030+
'Apply script',
1031+
'Apply settings file',
1032+
'Calculate build tree task graph',
1033+
'Calculate task graph',
1034+
'Configure build',
1035+
'Configure project',
1036+
'Compile build file',
1037+
'Compile script',
1038+
'Cross-configure project',
1039+
'Download',
1040+
'Evaluate settings',
1041+
'Execute countainer callback action',
1042+
'Execute',
1043+
'Executing',
1044+
'Finalize build cache configuration',
1045+
'Fingerprint transform inputs',
1046+
'Finish root build tree',
1047+
'Identifying work',
1048+
'Load build',
1049+
'Load projects',
1050+
'Notify afterEvaluate listeners',
1051+
'Notify beforeEvaluate listeners',
1052+
'Notify projectsEvaluated listeners',
1053+
'Notify projectsLoaded listeners',
1054+
'Notify task graph',
1055+
'Realize task',
1056+
'Register task',
1057+
'Resolve dependencies of',
1058+
'Resolve files of configuration',
1059+
'Resolve',
1060+
'Run init scripts',
1061+
'Run main tasks',
1062+
'Snapshot',
1063+
'Toolchain detection',
1064+
];
1065+
const prefix = prefixes.find((p) => name.startsWith(p));
1066+
if (prefix) {
1067+
newData.type = 'Text';
1068+
newData.text = name.slice(prefix.length + 1);
1069+
markers.name.push(stringTable.indexForString(prefix));
1070+
} else {
1071+
markers.name.push(stringTable.indexForString(name));
10101072

1011-
if (argData && 'type' in argData) {
1012-
argData.type2 = argData.type;
1013-
}
1014-
if (argData && 'category' in argData) {
1015-
argData.category2 = argData.category;
1016-
}
1073+
if (argData && 'type' in argData) {
1074+
argData.type2 = argData.type;
1075+
}
1076+
if (argData && 'category' in argData) {
1077+
argData.category2 = argData.category;
1078+
}
10171079

1018-
const newData = {
1019-
...argData,
1020-
type: name,
1021-
category: event.cat,
1022-
};
1080+
newData = {
1081+
...argData,
1082+
type: name,
1083+
category: event.cat,
1084+
};
1085+
}
10231086

10241087
// $FlowExpectError Opt out of Flow checking for this one.
10251088
markers.data.push(newData);

src/test/unit/__snapshots__/profile-conversion.test.js.snap

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345371,6 +345371,24 @@ Object {
345371345371
"tableLabel": "{marker.data.type2}",
345372345372
"tooltipLabel": "{marker.data.type2} - EventDispatch",
345373345373
},
345374+
Object {
345375+
"chartLabel": "{marker.data.text}",
345376+
"data": Array [
345377+
Object {
345378+
"format": "string",
345379+
"key": "text",
345380+
"label": "Description",
345381+
"searchable": true,
345382+
},
345383+
],
345384+
"display": Array [
345385+
"marker-chart",
345386+
"marker-table",
345387+
],
345388+
"name": "Text",
345389+
"tableLabel": "{marker.name} — {marker.data.text}",
345390+
"tooltipLabel": "{marker.name}",
345391+
},
345374345392
],
345375345393
"misc": "",
345376345394
"oscpu": "",
@@ -393833,6 +393851,24 @@ Object {
393833393851
"tableLabel": "{marker.data.type2}",
393834393852
"tooltipLabel": "{marker.data.type2} - EventDispatch",
393835393853
},
393854+
Object {
393855+
"chartLabel": "{marker.data.text}",
393856+
"data": Array [
393857+
Object {
393858+
"format": "string",
393859+
"key": "text",
393860+
"label": "Description",
393861+
"searchable": true,
393862+
},
393863+
],
393864+
"display": Array [
393865+
"marker-chart",
393866+
"marker-table",
393867+
],
393868+
"name": "Text",
393869+
"tableLabel": "{marker.name} — {marker.data.text}",
393870+
"tooltipLabel": "{marker.name}",
393871+
},
393836393872
],
393837393873
"misc": "",
393838393874
"oscpu": "",
@@ -442295,6 +442331,24 @@ Object {
442295442331
"tableLabel": "{marker.data.type2}",
442296442332
"tooltipLabel": "{marker.data.type2} - EventDispatch",
442297442333
},
442334+
Object {
442335+
"chartLabel": "{marker.data.text}",
442336+
"data": Array [
442337+
Object {
442338+
"format": "string",
442339+
"key": "text",
442340+
"label": "Description",
442341+
"searchable": true,
442342+
},
442343+
],
442344+
"display": Array [
442345+
"marker-chart",
442346+
"marker-table",
442347+
],
442348+
"name": "Text",
442349+
"tableLabel": "{marker.name} — {marker.data.text}",
442350+
"tooltipLabel": "{marker.name}",
442351+
},
442298442352
],
442299442353
"misc": "",
442300442354
"oscpu": "",
@@ -445179,6 +445233,24 @@ Object {
445179445233
"tableLabel": "{marker.data.type2}",
445180445234
"tooltipLabel": "{marker.data.type2} - EventDispatch",
445181445235
},
445236+
Object {
445237+
"chartLabel": "{marker.data.text}",
445238+
"data": Array [
445239+
Object {
445240+
"format": "string",
445241+
"key": "text",
445242+
"label": "Description",
445243+
"searchable": true,
445244+
},
445245+
],
445246+
"display": Array [
445247+
"marker-chart",
445248+
"marker-table",
445249+
],
445250+
"name": "Text",
445251+
"tableLabel": "{marker.name} — {marker.data.text}",
445252+
"tooltipLabel": "{marker.name}",
445253+
},
445182445254
],
445183445255
"misc": "",
445184445256
"oscpu": "",
@@ -448179,6 +448251,24 @@ Object {
448179448251
"tableLabel": "{marker.data.type2}",
448180448252
"tooltipLabel": "{marker.data.type2} - EventDispatch",
448181448253
},
448254+
Object {
448255+
"chartLabel": "{marker.data.text}",
448256+
"data": Array [
448257+
Object {
448258+
"format": "string",
448259+
"key": "text",
448260+
"label": "Description",
448261+
"searchable": true,
448262+
},
448263+
],
448264+
"display": Array [
448265+
"marker-chart",
448266+
"marker-table",
448267+
],
448268+
"name": "Text",
448269+
"tableLabel": "{marker.name} — {marker.data.text}",
448270+
"tooltipLabel": "{marker.name}",
448271+
},
448182448272
],
448183448273
"misc": "",
448184448274
"oscpu": "",
@@ -451772,6 +451862,24 @@ Object {
451772451862
"tableLabel": "{marker.data.type2}",
451773451863
"tooltipLabel": "{marker.data.type2} - EventDispatch",
451774451864
},
451865+
Object {
451866+
"chartLabel": "{marker.data.text}",
451867+
"data": Array [
451868+
Object {
451869+
"format": "string",
451870+
"key": "text",
451871+
"label": "Description",
451872+
"searchable": true,
451873+
},
451874+
],
451875+
"display": Array [
451876+
"marker-chart",
451877+
"marker-table",
451878+
],
451879+
"name": "Text",
451880+
"tableLabel": "{marker.name} — {marker.data.text}",
451881+
"tooltipLabel": "{marker.name}",
451882+
},
451775451883
],
451776451884
"misc": "",
451777451885
"oscpu": "",

0 commit comments

Comments
 (0)