diff --git a/CHANGELOG.md b/CHANGELOG.md index 92ee4f9..90c3a70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,9 @@ ## Unreleased * Compress data before sending -* Integrate Rails' new ActiveSupport::Editor feature in local profiler -* Fix Safari's incompatible date format bug in local profiler +* [local profiler] Integrate Rails' new ActiveSupport::Editor feature +* [local profiler] Toggle low impact sections visibility +* [local profiler] Fix Safari's incompatible date format bug ## 1.10.1 (2025-12-24) diff --git a/lib/rorvswild/local/javascript/local.js b/lib/rorvswild/local/javascript/local.js index 7c46596..b3d0bae 100644 --- a/lib/rorvswild/local/javascript/local.js +++ b/lib/rorvswild/local/javascript/local.js @@ -74,6 +74,18 @@ RorVsWild.Local.prototype.toggleCommand = function(event) { document.querySelector(event.currentTarget.dataset.target).classList.toggle("is-open") } +RorVsWild.Local.prototype.toggleLowImpactSections = function(event) { + var button = event.currentTarget + var sections = document.querySelectorAll(".rorvswild-local-panel__details__section[data-low-impact]") + var isHidden = sections[0].classList.contains("is-hidden") + + sections.forEach(function(section) { + section.classList.toggle("is-hidden") + }) + + button.textContent = isHidden ? "↑ Hide low impact sections" : "↓ View low impact sections" +} + RorVsWild.Local.prototype.expand = function() { this.active = true this.goToRequestDetail(event) @@ -190,9 +202,11 @@ RorVsWild.Local.Request.prototype.runtime = function() { RorVsWild.Local.Request.prototype.sections = function() { return this.data.sections.map(function(section) { var runtime = (section.total_runtime - section.children_runtime) + var impactValue = runtime * 100 / this.data.runtime return { id: RorVsWild.Local.nextId(), - impact: RorVsWild.Local.formatImpact(runtime * 100 / this.data.runtime), + impact: RorVsWild.Local.formatImpact(impactValue), + isLowImpact: impactValue < 1, language: RorVsWild.Local.kindToLanguage(section.kind), totalRuntime: RorVsWild.Local.relevantRounding(section.total_runtime), asyncRuntime: RorVsWild.Local.relevantRounding(section.async_runtime), @@ -213,6 +227,10 @@ RorVsWild.Local.Request.prototype.sections = function() { }.bind(this)).sort(function(a, b) { return b.selfRuntime - a.selfRuntime }) } +RorVsWild.Local.Request.prototype.hasLowImpactSections = function() { + return this.sections().some(function(section) { return section.isLowImpact }) +} + RorVsWild.Local.Request.prototype.sectionsImpactPerKind = function() { var total = 0 var perKind = this.sections().reduce(function(object, section) { diff --git a/lib/rorvswild/local/local.html.erb b/lib/rorvswild/local/local.html.erb index 224838b..d5d2239 100644 --- a/lib/rorvswild/local/local.html.erb +++ b/lib/rorvswild/local/local.html.erb @@ -148,6 +148,11 @@ {{#sections}} {{> RorVsWild.Local.Section}} {{/sections}} + {{#hasLowImpactSections}} +
+ +
+ {{/hasLowImpactSections}} @@ -162,7 +167,7 @@