@parca/profile 0.12.13 → 0.12.23
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 +12 -0
- package/package.json +3 -3
- package/src/IcicleGraph.tsx +36 -21
- package/src/ProfileView.tsx +1 -1
- package/src/TopTable.tsx +34 -21
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.12.23](https://github.com/parca-dev/parca/compare/ui-v0.12.22...ui-v0.12.23) (2022-04-25)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @parca/profile
|
|
9
|
+
|
|
10
|
+
## [0.12.20](https://github.com/parca-dev/parca/compare/ui-v0.12.19...ui-v0.12.20) (2022-04-12)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @parca/profile
|
|
13
|
+
|
|
14
|
+
## [0.12.14](https://github.com/parca-dev/parca/compare/ui-v0.12.13...ui-v0.12.14) (2022-04-06)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @parca/profile
|
|
17
|
+
|
|
6
18
|
## [0.12.13](https://github.com/parca-dev/parca/compare/ui-v0.12.12...ui-v0.12.13) (2022-04-05)
|
|
7
19
|
|
|
8
20
|
**Note:** Version bump only for package @parca/profile
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parca/profile",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.23",
|
|
4
4
|
"description": "Profile viewing libraries",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@parca/client": "^0.12.
|
|
6
|
+
"@parca/client": "^0.12.20",
|
|
7
7
|
"@parca/dynamicsize": "^0.12.0",
|
|
8
8
|
"@parca/parser": "^0.12.3",
|
|
9
9
|
"d3-scale": "^4.0.2"
|
|
@@ -19,5 +19,5 @@
|
|
|
19
19
|
"access": "public",
|
|
20
20
|
"registry": "https://registry.npmjs.org/"
|
|
21
21
|
},
|
|
22
|
-
"gitHead": "
|
|
22
|
+
"gitHead": "adfe17cad5627ceb7e3ba6ffa0a3806bf8b7b8b4"
|
|
23
23
|
}
|
package/src/IcicleGraph.tsx
CHANGED
|
@@ -5,8 +5,9 @@ import {scaleLinear} from 'd3-scale';
|
|
|
5
5
|
import {Flamegraph, FlamegraphNode, FlamegraphRootNode} from '@parca/client';
|
|
6
6
|
import {usePopper} from 'react-popper';
|
|
7
7
|
import {getLastItem, valueFormatter} from '@parca/functions';
|
|
8
|
+
import {useAppSelector, selectDarkMode} from '@parca/store';
|
|
8
9
|
|
|
9
|
-
const RowHeight =
|
|
10
|
+
const RowHeight = 26;
|
|
10
11
|
|
|
11
12
|
const icicleRectStyles = {
|
|
12
13
|
cursor: 'pointer',
|
|
@@ -65,7 +66,7 @@ function IcicleRect({
|
|
|
65
66
|
/>
|
|
66
67
|
{width > 5 && (
|
|
67
68
|
<svg width={width - 5} height={height}>
|
|
68
|
-
<text x={5} y={
|
|
69
|
+
<text x={5} y={15} style={{fontSize: '12px'}}>
|
|
69
70
|
{name}
|
|
70
71
|
</text>
|
|
71
72
|
</svg>
|
|
@@ -90,22 +91,6 @@ interface IcicleGraphNodesProps {
|
|
|
90
91
|
xScale: (value: number) => number;
|
|
91
92
|
}
|
|
92
93
|
|
|
93
|
-
function diffColor(diff: number, cumulative: number): string {
|
|
94
|
-
const prevValue = cumulative - diff;
|
|
95
|
-
const diffRatio = prevValue > 0 ? (Math.abs(diff) > 0 ? diff / prevValue : 0) : 1.0;
|
|
96
|
-
|
|
97
|
-
const diffTransparency =
|
|
98
|
-
Math.abs(diff) > 0 ? Math.min((Math.abs(diffRatio) / 2 + 0.5) * 0.8, 0.8) : 0;
|
|
99
|
-
const color =
|
|
100
|
-
diff === 0
|
|
101
|
-
? '#90c7e0'
|
|
102
|
-
: diff > 0
|
|
103
|
-
? `rgba(221, 46, 69, ${diffTransparency})`
|
|
104
|
-
: `rgba(59, 165, 93, ${diffTransparency})`;
|
|
105
|
-
|
|
106
|
-
return color;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
94
|
export function nodeLabel(node: FlamegraphNode.AsObject): string {
|
|
110
95
|
if (node.meta === undefined) return '<unknown>';
|
|
111
96
|
const mapping = `${
|
|
@@ -126,6 +111,26 @@ export function nodeLabel(node: FlamegraphNode.AsObject): string {
|
|
|
126
111
|
return fallback === '' ? '<unknown>' : fallback;
|
|
127
112
|
}
|
|
128
113
|
|
|
114
|
+
function diffColor(diff: number, cumulative: number, isDarkMode: boolean): string {
|
|
115
|
+
const prevValue = cumulative - diff;
|
|
116
|
+
const diffRatio = prevValue > 0 ? (Math.abs(diff) > 0 ? diff / prevValue : 0) : 1.0;
|
|
117
|
+
|
|
118
|
+
const diffTransparency =
|
|
119
|
+
Math.abs(diff) > 0 ? Math.min((Math.abs(diffRatio) / 2 + 0.5) * 0.8, 0.8) : 0;
|
|
120
|
+
|
|
121
|
+
const newSpanColor = isDarkMode ? '#B3BAE1' : '#929FEB';
|
|
122
|
+
const increasedSpanColor = isDarkMode
|
|
123
|
+
? `rgba(255, 177, 204, ${diffTransparency})`
|
|
124
|
+
: `rgba(254, 153, 187, ${diffTransparency})`;
|
|
125
|
+
const reducedSpanColor = isDarkMode
|
|
126
|
+
? `rgba(103, 158, 92, ${diffTransparency})`
|
|
127
|
+
: `rgba(164, 214, 153, ${diffTransparency})`;
|
|
128
|
+
|
|
129
|
+
const color = diff === 0 ? newSpanColor : diff > 0 ? increasedSpanColor : reducedSpanColor;
|
|
130
|
+
|
|
131
|
+
return color;
|
|
132
|
+
}
|
|
133
|
+
|
|
129
134
|
export function IcicleGraphNodes({
|
|
130
135
|
data,
|
|
131
136
|
x,
|
|
@@ -139,6 +144,8 @@ export function IcicleGraphNodes({
|
|
|
139
144
|
setCurPath,
|
|
140
145
|
curPath,
|
|
141
146
|
}: IcicleGraphNodesProps) {
|
|
147
|
+
const isDarkMode = useAppSelector(selectDarkMode);
|
|
148
|
+
|
|
142
149
|
const nodes =
|
|
143
150
|
curPath.length === 0 ? data : data.filter(d => d != null && curPath[0] === nodeLabel(d));
|
|
144
151
|
|
|
@@ -163,7 +170,7 @@ export function IcicleGraphNodes({
|
|
|
163
170
|
const name = nodeLabel(d);
|
|
164
171
|
const nextPath = path.concat([name]);
|
|
165
172
|
|
|
166
|
-
const color = diffColor(d.diff === undefined ? 0 : d.diff, d.cumulative);
|
|
173
|
+
const color = diffColor(d.diff === undefined ? 0 : d.diff, d.cumulative, isDarkMode);
|
|
167
174
|
|
|
168
175
|
const onClick = () => {
|
|
169
176
|
setCurPath(nextPath);
|
|
@@ -437,7 +444,9 @@ export function IcicleGraphRootNode({
|
|
|
437
444
|
setCurPath,
|
|
438
445
|
curPath,
|
|
439
446
|
}: IcicleGraphRootNodeProps) {
|
|
440
|
-
const
|
|
447
|
+
const isDarkMode = useAppSelector(selectDarkMode);
|
|
448
|
+
|
|
449
|
+
const color = diffColor(node.diff === undefined ? 0 : node.diff, node.cumulative, isDarkMode);
|
|
441
450
|
|
|
442
451
|
const onClick = () => setCurPath([]);
|
|
443
452
|
const onMouseEnter = () => setHoveringNode(node);
|
|
@@ -521,7 +530,13 @@ export default function IcicleGraph({graph, width, setCurPath, curPath}: IcicleG
|
|
|
521
530
|
hoveringNode={hoveringNode}
|
|
522
531
|
contextElement={svg.current}
|
|
523
532
|
/>
|
|
524
|
-
<svg
|
|
533
|
+
<svg
|
|
534
|
+
className="font-robotoMono"
|
|
535
|
+
width={width}
|
|
536
|
+
height={height}
|
|
537
|
+
onMouseMove={onMouseMove}
|
|
538
|
+
ref={svg}
|
|
539
|
+
>
|
|
525
540
|
<g ref={ref}>
|
|
526
541
|
<MemoizedIcicleGraphRootNode
|
|
527
542
|
node={graph.root}
|
package/src/ProfileView.tsx
CHANGED
|
@@ -236,7 +236,7 @@ export const ProfileView = ({
|
|
|
236
236
|
</div>
|
|
237
237
|
</div>
|
|
238
238
|
|
|
239
|
-
<div className="flex space-x-4">
|
|
239
|
+
<div className="flex space-x-4 justify-between">
|
|
240
240
|
{currentView === 'icicle' && (
|
|
241
241
|
<div className="w-full">
|
|
242
242
|
<CalcWidth throttle={300} delay={2000}>
|
package/src/TopTable.tsx
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
import * as parca_query_v1alpha1_query_pb from '@parca/client/src/parca/query/v1alpha1/query_pb';
|
|
10
10
|
import {getLastItem, valueFormatter} from '@parca/functions';
|
|
11
11
|
import {useGrpcMetadata} from '@parca/components';
|
|
12
|
+
import {useAppSelector, selectCompareMode} from '@parca/store';
|
|
12
13
|
|
|
13
14
|
import {ProfileSource} from './ProfileSource';
|
|
14
15
|
import './TopTable.styles.css';
|
|
@@ -138,6 +139,8 @@ export const TopTable = ({queryClient, profileSource}: ProfileViewProps): JSX.El
|
|
|
138
139
|
const {response, error} = useQuery(queryClient, profileSource);
|
|
139
140
|
const {items, requestSort, sortConfig} = useSortableData(response);
|
|
140
141
|
|
|
142
|
+
const compareMode = useAppSelector(selectCompareMode);
|
|
143
|
+
|
|
141
144
|
const unit = response?.toObject().top?.unit as string;
|
|
142
145
|
|
|
143
146
|
if (error != null) {
|
|
@@ -154,10 +157,18 @@ export const TopTable = ({queryClient, profileSource}: ProfileViewProps): JSX.El
|
|
|
154
157
|
return sortConfig.key === name ? sortConfig.direction : undefined;
|
|
155
158
|
};
|
|
156
159
|
|
|
160
|
+
const addPlusSign = (num: string) => {
|
|
161
|
+
if (num.charAt(0) === '0' || num.charAt(0) === '-') {
|
|
162
|
+
return num;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return `+${num}`;
|
|
166
|
+
};
|
|
167
|
+
|
|
157
168
|
return (
|
|
158
169
|
<>
|
|
159
|
-
<div className="w-full">
|
|
160
|
-
<table className="iciclegraph-table table-
|
|
170
|
+
<div className="w-full font-robotoMono">
|
|
171
|
+
<table className="iciclegraph-table table-fixed text-left w-full divide-y divide-gray-200 dark:divide-gray-700">
|
|
161
172
|
<thead className="bg-gray-50 dark:bg-gray-800">
|
|
162
173
|
<tr>
|
|
163
174
|
<th
|
|
@@ -170,7 +181,7 @@ export const TopTable = ({queryClient, profileSource}: ProfileViewProps): JSX.El
|
|
|
170
181
|
</span>
|
|
171
182
|
</th>
|
|
172
183
|
<th
|
|
173
|
-
className="text-
|
|
184
|
+
className="text-right text-sm cursor-pointer pt-2 pb-2 w-[150px]"
|
|
174
185
|
onClick={() => requestSort('flat')}
|
|
175
186
|
>
|
|
176
187
|
Flat
|
|
@@ -179,7 +190,7 @@ export const TopTable = ({queryClient, profileSource}: ProfileViewProps): JSX.El
|
|
|
179
190
|
</span>
|
|
180
191
|
</th>
|
|
181
192
|
<th
|
|
182
|
-
className="text-right text-sm cursor-pointer pt-2 pb-2 pr-2"
|
|
193
|
+
className="text-right text-sm cursor-pointer pt-2 pb-2 pr-2 w-[150px]"
|
|
183
194
|
onClick={() => requestSort('cumulative')}
|
|
184
195
|
>
|
|
185
196
|
Cumulative
|
|
@@ -189,32 +200,34 @@ export const TopTable = ({queryClient, profileSource}: ProfileViewProps): JSX.El
|
|
|
189
200
|
<Arrow direction={getClassNamesFor('cumulative')} />
|
|
190
201
|
</span>
|
|
191
202
|
</th>
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
<
|
|
199
|
-
|
|
200
|
-
|
|
203
|
+
{compareMode && (
|
|
204
|
+
<th
|
|
205
|
+
className="text-right text-sm cursor-pointer pt-2 pb-2 pr-2 w-[150px]"
|
|
206
|
+
onClick={() => requestSort('diff')}
|
|
207
|
+
>
|
|
208
|
+
Diff
|
|
209
|
+
<span className={`inline-block align-middle ml-2 ${getClassNamesFor('diff')}`}>
|
|
210
|
+
<Arrow direction={getClassNamesFor('diff')} />
|
|
211
|
+
</span>
|
|
212
|
+
</th>
|
|
213
|
+
)}
|
|
201
214
|
</tr>
|
|
202
215
|
</thead>
|
|
203
216
|
<tbody className="bg-white divide-y divide-gray-200 dark:bg-gray-900 dark:divide-gray-700">
|
|
204
217
|
{items?.map((report, index) => (
|
|
205
218
|
<tr key={index} className="hover:bg-[#62626212] dark:hover:bg-[#ffffff12]">
|
|
206
|
-
<td className="text-xs py-1.5 pl-2
|
|
207
|
-
|
|
208
|
-
</td>
|
|
209
|
-
<td className="text-xs min-w-[150px] max-w-[150px] py-1.5 text-right">
|
|
219
|
+
<td className="text-xs py-1.5 pl-2">{RowLabel(report.meta)}</td>
|
|
220
|
+
<td className="text-xs py-1.5 text-right">
|
|
210
221
|
{valueFormatter(report.flat, unit, 2)}
|
|
211
222
|
</td>
|
|
212
|
-
<td className="text-xs
|
|
223
|
+
<td className="text-xs py-1.5 text-right pr-2">
|
|
213
224
|
{valueFormatter(report.cumulative, unit, 2)}
|
|
214
225
|
</td>
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
226
|
+
{compareMode && (
|
|
227
|
+
<td className="text-xs py-1.5 text-right pr-2">
|
|
228
|
+
{addPlusSign(valueFormatter(report.diff, unit, 2))}
|
|
229
|
+
</td>
|
|
230
|
+
)}
|
|
218
231
|
</tr>
|
|
219
232
|
))}
|
|
220
233
|
</tbody>
|