Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve DevTools Profiler commit-selector UX #20943

Merged
merged 2 commits into from
Mar 8, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use natural log for snapshot selector bar height, linear for color
  • Loading branch information
Brian Vaughn committed Mar 8, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 07b415599f5619eea8917a8a74ee628564e944fa
Original file line number Diff line number Diff line change
@@ -40,12 +40,21 @@ function SnapshotCommitListItem({data: itemData, index, style}: Props) {
const commitDuration = commitDurations[index];
const commitTime = commitTimes[index];

// Guard against commits with duration 0
const percentage =
// Use natural log for bar height.
// This prevents one (or a few) outliers from squishing the majority of other commits.
// So rather than e.g. _█_ we get something more like e.g. ▄█_
const heightScale =
Math.min(
1,
Math.max(0, Math.log(commitDuration) / Math.log(maxDuration)),
) || 0;

// Use a linear scale for color.
// This gives some visual contrast between cheaper and more expensive commits
// and somewhat compensates for the log scale height.
const colorScale =
Math.min(1, Math.max(0, commitDuration / maxDuration)) || 0;

const isSelected = selectedCommitIndex === index;

// Leave a 1px gap between snapshots
@@ -80,9 +89,9 @@ function SnapshotCommitListItem({data: itemData, index, style}: Props) {
<div
className={styles.Inner}
style={{
height: `${Math.round(percentage * 100)}%`,
height: `${Math.round(heightScale * 100)}%`,
backgroundColor:
commitDuration > 0 ? getGradientColor(percentage) : undefined,
commitDuration > 0 ? getGradientColor(colorScale) : undefined,
}}
/>
</div>