@parca/profile 0.12.14 → 0.12.25

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 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.25](https://github.com/parca-dev/parca/compare/ui-v0.12.24...ui-v0.12.25) (2022-04-27)
7
+
8
+ **Note:** Version bump only for package @parca/profile
9
+
10
+ ## [0.12.23](https://github.com/parca-dev/parca/compare/ui-v0.12.22...ui-v0.12.23) (2022-04-25)
11
+
12
+ **Note:** Version bump only for package @parca/profile
13
+
14
+ ## [0.12.20](https://github.com/parca-dev/parca/compare/ui-v0.12.19...ui-v0.12.20) (2022-04-12)
15
+
16
+ **Note:** Version bump only for package @parca/profile
17
+
6
18
  ## [0.12.14](https://github.com/parca-dev/parca/compare/ui-v0.12.13...ui-v0.12.14) (2022-04-06)
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.14",
3
+ "version": "0.12.25",
4
4
  "description": "Profile viewing libraries",
5
5
  "dependencies": {
6
- "@parca/client": "^0.12.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": "97cf7186818dc4aaba311e4c2347353bca08fca4"
22
+ "gitHead": "813bcc35b44f8b4a16c200ae1c25a2d46b476e59"
23
23
  }
@@ -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 = 20;
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={13} style={{fontSize: '12px'}}>
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 color = diffColor(node.diff === undefined ? 0 : node.diff, node.cumulative);
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 width={width} height={height} onMouseMove={onMouseMove} ref={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}
@@ -204,7 +204,7 @@ export const ProfileView = ({
204
204
  color="neutral"
205
205
  onClick={resetIcicleGraph}
206
206
  disabled={curPath.length === 0}
207
- additionalClasses="whitespace-nowrap text-ellipsis"
207
+ className="whitespace-nowrap text-ellipsis"
208
208
  >
209
209
  Reset View
210
210
  </Button>
@@ -212,7 +212,7 @@ export const ProfileView = ({
212
212
 
213
213
  <Button
214
214
  color={`${currentView === 'table' ? 'primary' : 'neutral'}`}
215
- additionalClasses={`rounded-tr-none rounded-br-none w-auto px-8 whitespace-nowrap text-ellipsis no-outline-on-buttons`}
215
+ className="rounded-tr-none rounded-br-none w-auto px-8 whitespace-nowrap text-ellipsis no-outline-on-buttons"
216
216
  onClick={() => switchProfileView('table')}
217
217
  >
218
218
  Table
@@ -220,7 +220,7 @@ export const ProfileView = ({
220
220
 
221
221
  <Button
222
222
  color={`${currentView === 'both' ? 'primary' : 'neutral'}`}
223
- additionalClasses={`rounded-tl-none rounded-tr-none rounded-bl-none rounded-br-none border-l-0 border-r-0 w-auto px-8 whitespace-nowrap no-outline-on-buttons no-outline-on-buttons text-ellipsis`}
223
+ className="rounded-tl-none rounded-tr-none rounded-bl-none rounded-br-none border-l-0 border-r-0 w-auto px-8 whitespace-nowrap no-outline-on-buttons no-outline-on-buttons text-ellipsis"
224
224
  onClick={() => switchProfileView('both')}
225
225
  >
226
226
  Both
@@ -228,7 +228,7 @@ export const ProfileView = ({
228
228
 
229
229
  <Button
230
230
  color={`${currentView === 'icicle' ? 'primary' : 'neutral'}`}
231
- additionalClasses={`rounded-tl-none rounded-bl-none w-auto px-8 whitespace-nowrap text-ellipsis no-outline-on-buttons`}
231
+ className="rounded-tl-none rounded-bl-none w-auto px-8 whitespace-nowrap text-ellipsis no-outline-on-buttons"
232
232
  onClick={() => switchProfileView('icicle')}
233
233
  >
234
234
  Icicle Graph
package/src/TopTable.tsx CHANGED
@@ -167,7 +167,7 @@ export const TopTable = ({queryClient, profileSource}: ProfileViewProps): JSX.El
167
167
 
168
168
  return (
169
169
  <>
170
- <div className="w-full">
170
+ <div className="w-full font-robotoMono">
171
171
  <table className="iciclegraph-table table-fixed text-left w-full divide-y divide-gray-200 dark:divide-gray-700">
172
172
  <thead className="bg-gray-50 dark:bg-gray-800">
173
173
  <tr>