@parca/profile 0.16.82 → 0.16.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/IcicleGraph.js +10 -4
- package/dist/ProfileView/index.js +3 -6
- package/dist/{TopTable.d.ts → TopTable/index.d.ts} +2 -2
- package/dist/TopTable/index.js +134 -0
- package/dist/components/ProfileShareButton/index.d.ts +2 -1
- package/dist/components/ProfileShareButton/index.js +3 -3
- package/dist/styles.css +1 -1
- package/package.json +4 -4
- package/src/IcicleGraph.tsx +12 -5
- package/src/ProfileView/index.tsx +50 -48
- package/src/TopTable/benchmarks/TopTable-10M.benchmark.tsx +33 -0
- package/src/TopTable/benchmarks/TopTable-1M.benchmark.tsx +33 -0
- package/src/TopTable/benchmarks/TopTable-20M.benchmark.tsx +33 -0
- package/src/TopTable/benchmarks/benchdata/populateData.js +91 -0
- package/src/TopTable/index.tsx +175 -0
- package/src/components/ProfileShareButton/index.tsx +3 -2
- package/tsconfig.json +8 -1
- package/dist/TopTable.js +0 -144
- package/src/TopTable.tsx +0 -270
package/src/TopTable.tsx
DELETED
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
// Copyright 2022 The Parca Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
|
|
14
|
-
import React from 'react';
|
|
15
|
-
|
|
16
|
-
import {getLastItem, valueFormatter, isSearchMatch} from '@parca/functions';
|
|
17
|
-
import {
|
|
18
|
-
useAppSelector,
|
|
19
|
-
selectCompareMode,
|
|
20
|
-
selectSearchNodeString,
|
|
21
|
-
setSearchNodeString,
|
|
22
|
-
useAppDispatch,
|
|
23
|
-
} from '@parca/store';
|
|
24
|
-
import {TopNode, TopNodeMeta, Top} from '@parca/client';
|
|
25
|
-
|
|
26
|
-
import {hexifyAddress} from './utils';
|
|
27
|
-
|
|
28
|
-
import './TopTable.styles.css';
|
|
29
|
-
|
|
30
|
-
interface TopTableProps {
|
|
31
|
-
data?: Top;
|
|
32
|
-
sampleUnit: string;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const Arrow = ({direction}: {direction: string | undefined}): JSX.Element => {
|
|
36
|
-
return (
|
|
37
|
-
<svg
|
|
38
|
-
className={`${direction !== undefined ? 'fill-[#161616] dark:fill-[#ffffff]' : ''}`}
|
|
39
|
-
fill="#777d87"
|
|
40
|
-
height="10"
|
|
41
|
-
viewBox="0 0 11 10"
|
|
42
|
-
width="11"
|
|
43
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
44
|
-
>
|
|
45
|
-
<path clipRule="evenodd" d="m.573997 0 5.000003 10 5-10h-9.999847z" fillRule="evenodd" />
|
|
46
|
-
</svg>
|
|
47
|
-
);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const useSortableData = (
|
|
51
|
-
top?: Top,
|
|
52
|
-
config: {key: keyof TopNode | 'name'; direction: 'asc' | 'desc'} = {
|
|
53
|
-
key: 'cumulative',
|
|
54
|
-
direction: 'desc',
|
|
55
|
-
}
|
|
56
|
-
): {
|
|
57
|
-
items:
|
|
58
|
-
| Array<{
|
|
59
|
-
diff: number;
|
|
60
|
-
cumulative: number;
|
|
61
|
-
flat: number;
|
|
62
|
-
name: string | undefined;
|
|
63
|
-
meta?: TopNodeMeta | undefined;
|
|
64
|
-
}>
|
|
65
|
-
| undefined;
|
|
66
|
-
requestSort: (key: keyof TopNode | 'name') => void;
|
|
67
|
-
sortConfig: {key: keyof TopNode | 'name'; direction: string} | null;
|
|
68
|
-
} => {
|
|
69
|
-
const [sortConfig, setSortConfig] = React.useState<{
|
|
70
|
-
key: keyof TopNode | 'name';
|
|
71
|
-
direction: string;
|
|
72
|
-
} | null>(config);
|
|
73
|
-
|
|
74
|
-
const rawTableReport = top != null ? top.list : [];
|
|
75
|
-
|
|
76
|
-
const items = rawTableReport.map(node => ({
|
|
77
|
-
...node,
|
|
78
|
-
// Warning: string to number can overflow
|
|
79
|
-
// https://github.com/timostamm/protobuf-ts/blob/master/MANUAL.md#bigint-support
|
|
80
|
-
diff: Number(node.diff),
|
|
81
|
-
cumulative: Number(node.cumulative),
|
|
82
|
-
flat: Number(node.flat),
|
|
83
|
-
name: node.meta?.function?.name,
|
|
84
|
-
}));
|
|
85
|
-
|
|
86
|
-
const sortedItems = React.useMemo(() => {
|
|
87
|
-
if (items.length === 0) return;
|
|
88
|
-
|
|
89
|
-
const sortableItems = [...items];
|
|
90
|
-
if (sortConfig !== null) {
|
|
91
|
-
sortableItems.sort((a, b) => {
|
|
92
|
-
const itemA = a[sortConfig.key];
|
|
93
|
-
const itemB = b[sortConfig.key];
|
|
94
|
-
if (itemA === undefined && itemB === undefined) {
|
|
95
|
-
return 0;
|
|
96
|
-
}
|
|
97
|
-
if (itemA === undefined) {
|
|
98
|
-
return sortConfig.direction === 'asc' ? -1 : 1;
|
|
99
|
-
}
|
|
100
|
-
if (itemB === undefined) {
|
|
101
|
-
return sortConfig.direction === 'asc' ? 1 : -1;
|
|
102
|
-
}
|
|
103
|
-
if (itemA < itemB) {
|
|
104
|
-
return sortConfig.direction === 'asc' ? -1 : 1;
|
|
105
|
-
}
|
|
106
|
-
if (itemA > itemB) {
|
|
107
|
-
return sortConfig.direction === 'asc' ? 1 : -1;
|
|
108
|
-
}
|
|
109
|
-
return 0;
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
return sortableItems;
|
|
113
|
-
}, [items, sortConfig]);
|
|
114
|
-
|
|
115
|
-
const requestSort = (key: keyof TopNode | 'name'): void => {
|
|
116
|
-
let direction = 'desc';
|
|
117
|
-
if (sortConfig != null && sortConfig.key === key && sortConfig.direction === 'desc') {
|
|
118
|
-
direction = 'asc';
|
|
119
|
-
}
|
|
120
|
-
setSortConfig({key, direction});
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
return {items: sortedItems, requestSort, sortConfig};
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
export const RowLabel = (meta: TopNodeMeta | undefined): string => {
|
|
127
|
-
if (meta === undefined) return '<unknown>';
|
|
128
|
-
const mapping = `${
|
|
129
|
-
meta?.mapping?.file !== undefined && meta?.mapping?.file !== ''
|
|
130
|
-
? `[${getLastItem(meta.mapping.file) ?? ''}]`
|
|
131
|
-
: ''
|
|
132
|
-
}`;
|
|
133
|
-
if (meta.function?.name !== undefined && meta.function?.name !== '')
|
|
134
|
-
return `${mapping} ${meta.function.name}`;
|
|
135
|
-
|
|
136
|
-
const address = hexifyAddress(meta.location?.address);
|
|
137
|
-
const fallback = `${mapping} ${address}`;
|
|
138
|
-
|
|
139
|
-
return fallback === '' ? '<unknown>' : fallback;
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
export const TopTable = ({data: top, sampleUnit}: TopTableProps): JSX.Element => {
|
|
143
|
-
const {items, requestSort, sortConfig} = useSortableData(top);
|
|
144
|
-
const currentSearchString = useAppSelector(selectSearchNodeString);
|
|
145
|
-
const compareMode = useAppSelector(selectCompareMode);
|
|
146
|
-
const dispatch = useAppDispatch();
|
|
147
|
-
|
|
148
|
-
const unit = sampleUnit;
|
|
149
|
-
|
|
150
|
-
const total = top != null ? top.list.length : 0;
|
|
151
|
-
if (total === 0) return <>Profile has no samples</>;
|
|
152
|
-
|
|
153
|
-
const getClassNamesFor = (name: string): string | undefined => {
|
|
154
|
-
if (sortConfig == null) {
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
return sortConfig.key === name ? sortConfig.direction : undefined;
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
const addPlusSign = (num: string): string => {
|
|
161
|
-
if (num.charAt(0) === '0' || num.charAt(0) === '-') {
|
|
162
|
-
return num;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return `+${num}`;
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
const selectSpan = (span: string): void => {
|
|
169
|
-
dispatch(setSearchNodeString(span.trim()));
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
return (
|
|
173
|
-
<>
|
|
174
|
-
<div className="w-full font-robotoMono">
|
|
175
|
-
<table
|
|
176
|
-
className="iciclegraph-table table-fixed text-left w-full divide-y divide-gray-200 dark:divide-gray-700"
|
|
177
|
-
tabIndex={1}
|
|
178
|
-
>
|
|
179
|
-
<thead className="bg-gray-50 dark:bg-gray-800">
|
|
180
|
-
<tr>
|
|
181
|
-
<th
|
|
182
|
-
className="text-sm cursor-pointer pt-2 pb-2 pl-2"
|
|
183
|
-
onClick={() => requestSort('name')}
|
|
184
|
-
>
|
|
185
|
-
Name
|
|
186
|
-
<span
|
|
187
|
-
className={`inline-block align-middle ml-2 ${getClassNamesFor('name') ?? ''}`}
|
|
188
|
-
>
|
|
189
|
-
<Arrow direction={getClassNamesFor('name')} />
|
|
190
|
-
</span>
|
|
191
|
-
</th>
|
|
192
|
-
<th
|
|
193
|
-
className="text-right text-sm cursor-pointer pt-2 pb-2 w-[150px]"
|
|
194
|
-
onClick={() => requestSort('flat')}
|
|
195
|
-
>
|
|
196
|
-
Flat
|
|
197
|
-
<span
|
|
198
|
-
className={`inline-block align-middle ml-2 ${getClassNamesFor('flat') ?? ''}`}
|
|
199
|
-
>
|
|
200
|
-
<Arrow direction={getClassNamesFor('flat')} />
|
|
201
|
-
</span>
|
|
202
|
-
</th>
|
|
203
|
-
<th
|
|
204
|
-
className="text-right text-sm cursor-pointer pt-2 pb-2 pr-2 w-[150px]"
|
|
205
|
-
onClick={() => requestSort('cumulative')}
|
|
206
|
-
>
|
|
207
|
-
Cumulative
|
|
208
|
-
<span
|
|
209
|
-
className={`inline-block align-middle ml-2 ${
|
|
210
|
-
getClassNamesFor('cumulative') ?? ''
|
|
211
|
-
}`}
|
|
212
|
-
>
|
|
213
|
-
<Arrow direction={getClassNamesFor('cumulative')} />
|
|
214
|
-
</span>
|
|
215
|
-
</th>
|
|
216
|
-
{compareMode && (
|
|
217
|
-
<th
|
|
218
|
-
className="text-right text-sm cursor-pointer pt-2 pb-2 pr-2 w-[150px]"
|
|
219
|
-
onClick={() => requestSort('diff')}
|
|
220
|
-
>
|
|
221
|
-
Diff
|
|
222
|
-
<span
|
|
223
|
-
className={`inline-block align-middle ml-2 ${getClassNamesFor('diff') ?? ''}`}
|
|
224
|
-
>
|
|
225
|
-
<Arrow direction={getClassNamesFor('diff')} />
|
|
226
|
-
</span>
|
|
227
|
-
</th>
|
|
228
|
-
)}
|
|
229
|
-
</tr>
|
|
230
|
-
</thead>
|
|
231
|
-
<tbody className="bg-white divide-y divide-gray-200 dark:bg-gray-900 dark:divide-gray-700">
|
|
232
|
-
{items?.map((report, index) => {
|
|
233
|
-
const name = RowLabel(report.meta);
|
|
234
|
-
return (
|
|
235
|
-
<tr
|
|
236
|
-
key={index}
|
|
237
|
-
className="hover:bg-[#62626212] dark:hover:bg-[#ffffff12] cursor-pointer"
|
|
238
|
-
style={{
|
|
239
|
-
opacity:
|
|
240
|
-
currentSearchString !== undefined &&
|
|
241
|
-
currentSearchString !== '' &&
|
|
242
|
-
!isSearchMatch(currentSearchString, name)
|
|
243
|
-
? 0.5
|
|
244
|
-
: 1,
|
|
245
|
-
}}
|
|
246
|
-
onClick={() => selectSpan(name)}
|
|
247
|
-
>
|
|
248
|
-
<td className="text-xs py-1.5 pl-2">{name}</td>
|
|
249
|
-
<td className="text-xs py-1.5 text-right">
|
|
250
|
-
{valueFormatter(report.flat, unit, 2)}
|
|
251
|
-
</td>
|
|
252
|
-
<td className="text-xs py-1.5 text-right pr-2">
|
|
253
|
-
{valueFormatter(report.cumulative, unit, 2)}
|
|
254
|
-
</td>
|
|
255
|
-
{compareMode && (
|
|
256
|
-
<td className="text-xs py-1.5 text-right pr-2">
|
|
257
|
-
{addPlusSign(valueFormatter(report.diff, unit, 2))}
|
|
258
|
-
</td>
|
|
259
|
-
)}
|
|
260
|
-
</tr>
|
|
261
|
-
);
|
|
262
|
-
})}
|
|
263
|
-
</tbody>
|
|
264
|
-
</table>
|
|
265
|
-
</div>
|
|
266
|
-
</>
|
|
267
|
-
);
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
export default TopTable;
|