11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
# File 'lib/heapscope/report/html.rb', line 11
def render(report)
data = report.to_h
<<~HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>HeapScope Report — #{escape(report.summary[:healthy] ? "HEALTHY" : "ATTENTION")}</title>
<style>
:root {
--bg0: #f4f7f6;
--bg1: #e8eef0;
--ink: #14201c;
--muted: #5b6b66;
--accent: #0f766e;
--accent2: #334155;
--card: #ffffffcc;
--high: #b91c1c;
--med: #c2410c;
--low: #57534e;
--ok: #047857;
}
* { box-sizing: border-box; }
body {
margin: 0;
font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
color: var(--ink);
background:
radial-gradient(1200px 600px at 10% -10%, #ccfbf1 0%, transparent 55%),
radial-gradient(900px 500px at 100% 0%, #e2e8f0 0%, transparent 50%),
linear-gradient(165deg, var(--bg0), var(--bg1));
min-height: 100vh;
}
header.hero {
padding: 2.5rem 1.25rem 1.5rem;
max-width: 1040px;
margin: 0 auto;
display: grid;
grid-template-columns: 72px 1fr;
gap: 1.25rem;
align-items: center;
}
header.hero svg { width: 72px; height: 72px; }
h1 {
font-family: "IBM Plex Serif", Georgia, serif;
font-weight: 650;
letter-spacing: -0.03em;
font-size: clamp(2rem, 4vw, 2.75rem);
margin: 0;
}
.tagline { color: var(--muted); margin: 0.35rem 0 0; }
main { max-width: 1040px; margin: 0 auto; padding: 0 1.25rem 4rem; }
.banner {
padding: 1rem 1.25rem;
background: var(--card);
backdrop-filter: blur(8px);
border-left: 5px solid var(--accent);
border-radius: 0 12px 12px 0;
margin: 1rem 0 1.5rem;
}
.banner.ok { border-left-color: var(--ok); }
.banner.warn { border-left-color: var(--med); }
h2 {
margin-top: 2.25rem;
font-size: 0.85rem;
color: var(--accent);
text-transform: uppercase;
letter-spacing: 0.08em;
}
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 0.75rem;
}
.stat {
background: var(--card);
border-radius: 12px;
padding: 1rem;
border: 1px solid #d6e0dc;
}
.stat .label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat .value { font-size: 1.35rem; font-weight: 600; margin-top: 0.25rem; }
table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 12px; overflow: hidden; }
th, td { text-align: left; padding: 0.55rem 0.7rem; border-bottom: 1px solid #e4ebe8; font-size: 0.92rem; }
th { background: #f0f5f3; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.sev-high { color: var(--high); font-weight: 650; }
.sev-medium { color: var(--med); font-weight: 600; }
.sev-low { color: var(--low); }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 48px; margin: 0.5rem 0 1rem; }
.bars span {
display: block;
width: 10px;
background: linear-gradient(180deg, #2dd4bf, #0f766e);
border-radius: 3px 3px 0 0;
min-height: 2px;
}
pre {
background: #0f172a;
color: #e2e8f0;
padding: 1rem;
overflow: auto;
font-size: 0.78rem;
border-radius: 12px;
max-height: 420px;
}
.note { font-size: 0.85rem; color: var(--muted); }
footer { margin-top: 3rem; color: var(--muted); font-size: 0.85rem; }
@media (max-width: 640px) {
header.hero { grid-template-columns: 1fr; }
}
</style>
</head>
<body>
<header class="hero">
#{logo_svg}
<div>
<h1>HeapScope</h1>
<p class="tagline">Retention-first diagnostics · v#{escape(report.heapscope_version)} · Ruby #{escape(report.runtime_info[:ruby])} · schema #{report.schema_version}</p>
</div>
</header>
<main>
<div class="banner #{report.summary[:healthy] ? "ok" : "warn"}">
<strong>#{report.summary[:healthy] ? "HEALTHY" : "ATTENTION"}</strong>
<div class="note">#{escape(Scorecard.from_report(report).to_text.lines[2..5]&.join(' ') || 'Estimates are approximate.')}</div>
<div class="note">Object values are not included by default. Facts ≠ hypotheses.</div>
</div>
<h2>Memory overview</h2>
<div class="grid">
<div class="stat"><div class="label">RSS before</div><div class="value">#{bytes(report.before&.)}</div></div>
<div class="stat"><div class="label">RSS after</div><div class="value">#{bytes(report.after&.)}</div></div>
<div class="stat"><div class="label">RSS Δ</div><div class="value">#{bytes(report.diff&.)}</div></div>
<div class="stat"><div class="label">Live slots Δ</div><div class="value">#{report.diff&.heap_live_delta || "n/a"}</div></div>
<div class="stat"><div class="label">Retention</div><div class="value">#{ratio(report.diff&.retention_ratio)}</div></div>
<div class="stat"><div class="label">Findings</div><div class="value">#{report.findings.size}</div></div>
</div>
#{sparkline_section(report)}
<h2>Top class growth</h2>
<table>
<tr><th>Class</th><th>Before</th><th>After</th><th>Delta</th><th>Bytes Δ</th></tr>
#{class_rows(report)}
</table>
<h2>Top suspects</h2>
#{suspect_blocks(report)}
<h2>Findings</h2>
#{finding_blocks(report)}
<h2>Next steps</h2>
#{next_step_blocks(report)}
<h2>Limitations</h2>
<p class="note">#{report.limitations.empty? ? "None recorded." : escape(report.limitations.join(", "))}</p>
<h2>Raw JSON</h2>
<pre>#{escape(JSON.pretty_generate(data))}</pre>
<footer>
#{Branding.}
</footer>
</main>
</body>
</html>
HTML
end
|