Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
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
20 changes: 18 additions & 2 deletions 20 Lib/profiling/sampling/_heatmap_assets/heatmap.css
Original file line number Diff line number Diff line change
Expand Up @@ -1094,18 +1094,34 @@
}

#scroll_marker .marker.cold {
background: var(--heat-1);
}

#scroll_marker .marker.cool {
background: var(--heat-2);
}

#scroll_marker .marker.mild {
background: var(--heat-3);
}

#scroll_marker .marker.warm {
background: var(--heat-5);
background: var(--heat-4);
}

#scroll_marker .marker.hot {
background: var(--heat-5);
}

#scroll_marker .marker.very-hot {
background: var(--heat-6);
}

#scroll_marker .marker.intense {
background: var(--heat-7);
}

#scroll_marker .marker.vhot {
#scroll_marker .marker.extreme {
background: var(--heat-8);
}

Expand Down
49 changes: 19 additions & 30 deletions 49 Lib/profiling/sampling/_heatmap_assets/heatmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function toggleTheme() {
if (btn) {
btn.innerHTML = next === 'dark' ? '☼' : '☾'; // sun or moon
}
applyLineColors();

// Rebuild scroll marker with new theme colors
buildScrollMarker();
Expand Down Expand Up @@ -160,13 +161,6 @@ function getSampleCount(line) {
return parseInt(text) || 0;
}

function getIntensityClass(ratio) {
if (ratio > 0.75) return 'vhot';
if (ratio > 0.5) return 'hot';
if (ratio > 0.25) return 'warm';
return 'cold';
}

// ============================================================================
// Scroll Minimap
// ============================================================================
Expand Down Expand Up @@ -194,7 +188,7 @@ function buildScrollMarker() {

const lineTop = Math.floor(line.offsetTop * markerScale);
const lineNumber = index + 1;
const intensityClass = maxSamples > 0 ? getIntensityClass(samples / maxSamples) : 'cold';
const intensityClass = maxSamples > 0 ? (intensityToClass(samples / maxSamples) || 'cold') : 'cold';

if (lineNumber === prevLine + 1 && lastMark?.classList.contains(intensityClass)) {
lastMark.style.height = `${lineTop + lineHeight - lastTop}px`;
Expand All @@ -212,6 +206,21 @@ function buildScrollMarker() {
document.body.appendChild(scrollMarker);
}

function applyLineColors() {
const lines = document.querySelectorAll('.code-line');
lines.forEach(line => {
let intensity;
if (colorMode === 'self') {
intensity = parseFloat(line.getAttribute('data-self-intensity')) || 0;
} else {
intensity = parseFloat(line.getAttribute('data-cumulative-intensity')) || 0;
}

const color = intensityToColor(intensity);
line.style.background = color;
});
}

// ============================================================================
// Toggle Controls
// ============================================================================
Expand Down Expand Up @@ -264,20 +273,7 @@ function applyHotFilter() {

function toggleColorMode() {
colorMode = colorMode === 'self' ? 'cumulative' : 'self';
const lines = document.querySelectorAll('.code-line');

lines.forEach(line => {
let bgColor;
if (colorMode === 'self') {
bgColor = line.getAttribute('data-self-color');
} else {
bgColor = line.getAttribute('data-cumulative-color');
}

if (bgColor) {
line.style.background = bgColor;
}
});
applyLineColors();

updateToggleUI('toggle-color-mode', colorMode === 'cumulative');

Expand All @@ -295,14 +291,7 @@ function toggleColorMode() {
document.addEventListener('DOMContentLoaded', function() {
// Restore UI state (theme, etc.)
restoreUIState();

// Apply background colors
document.querySelectorAll('.code-line[data-bg-color]').forEach(line => {
const bgColor = line.getAttribute('data-bg-color');
if (bgColor) {
line.style.background = bgColor;
}
});
applyLineColors();

// Initialize navigation buttons
document.querySelectorAll('.nav-btn').forEach(button => {
Expand Down
16 changes: 16 additions & 0 deletions 16 Lib/profiling/sampling/_heatmap_assets/heatmap_index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
// Tachyon Profiler - Heatmap Index JavaScript
// Index page specific functionality

// ============================================================================
// Heatmap Bar Coloring
// ============================================================================

function applyHeatmapBarColors() {
const bars = document.querySelectorAll('.heatmap-bar[data-intensity]');
bars.forEach(bar => {
const intensity = parseFloat(bar.getAttribute('data-intensity')) || 0;
const color = intensityToColor(intensity);
bar.style.backgroundColor = color;
});
}

// ============================================================================
// Theme Support
// ============================================================================
Expand All @@ -17,6 +30,8 @@ function toggleTheme() {
if (btn) {
btn.innerHTML = next === 'dark' ? '☼' : '☾'; // sun or moon
}

applyHeatmapBarColors();
}

function restoreUIState() {
Expand Down Expand Up @@ -108,4 +123,5 @@ function collapseAll() {

document.addEventListener('DOMContentLoaded', function() {
restoreUIState();
applyHeatmapBarColors();
});
40 changes: 40 additions & 0 deletions 40 Lib/profiling/sampling/_heatmap_assets/heatmap_shared.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Tachyon Profiler - Shared Heatmap JavaScript
// Common utilities shared between index and file views

// ============================================================================
// Heat Level Mapping (Single source of truth for intensity thresholds)
// ============================================================================

// Maps intensity (0-1) to heat level (0-8). Level 0 = no heat, 1-8 = heat levels.
function intensityToHeatLevel(intensity) {
if (intensity <= 0) return 0;
if (intensity <= 0.125) return 1;
if (intensity <= 0.25) return 2;
if (intensity <= 0.375) return 3;
if (intensity <= 0.5) return 4;
if (intensity <= 0.625) return 5;
if (intensity <= 0.75) return 6;
if (intensity <= 0.875) return 7;
return 8;
}

// Class names corresponding to heat levels 1-8 (used by scroll marker)
const HEAT_CLASS_NAMES = ['cold', 'cool', 'mild', 'warm', 'hot', 'very-hot', 'intense', 'extreme'];

function intensityToClass(intensity) {
const level = intensityToHeatLevel(intensity);
return level === 0 ? null : HEAT_CLASS_NAMES[level - 1];
}

// ============================================================================
// Color Mapping (Intensity to Heat Color)
// ============================================================================

function intensityToColor(intensity) {
const level = intensityToHeatLevel(intensity);
if (level === 0) {
return 'transparent';
}
const rootStyle = getComputedStyle(document.documentElement);
return rootStyle.getPropertyValue(`--heat-${level}`).trim();
}
Loading
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.