@samitouri / QOS-React-2 / commits / 5fe091c778

Swap log with cbrt for commit bar height (#20952)

Brian Vaughn committed Mar 8, 2021 at 14:02 UTC 5fe091c778f61fd81d226e65c0bc094c6380c88a
1 file changed +3 -3
packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotCommitListItem.js
+3 -3
@@ -40,18 +40,18 @@ function SnapshotCommitListItem({data: itemData, index, style}: Props) {
40 const commitDuration = commitDurations[index];
41 const commitTime = commitTimes[index];
42
43 - // Use natural log for bar height.
43 + // Use natural cbrt for bar height.
44 // This prevents one (or a few) outliers from squishing the majority of other commits.
45 // So rather than e.g. _█_ we get something more like e.g. ▄█_
46 const heightScale =
47 Math.min(
48 1,
49 - Math.max(0, Math.log(commitDuration) / Math.log(maxDuration)),
49 + Math.max(0, Math.cbrt(commitDuration) / Math.cbrt(maxDuration)),
50 ) || 0;
51
52 // Use a linear scale for color.
53 // This gives some visual contrast between cheaper and more expensive commits
54 - // and somewhat compensates for the log scale height.
54 + // and somewhat compensates for the cbrt scale height.
55 const colorScale =
56 Math.min(1, Math.max(0, commitDuration / maxDuration)) || 0;
57