Skip to content

Commit dd70432

Browse files
committed
updating tests
1 parent 0441821 commit dd70432

10 files changed

Lines changed: 585 additions & 25 deletions

File tree

lisa/lisa-analyses/imp-testcases/visualization/all-flame/assets/style.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,11 @@ g.edge>text {
232232
#heatmap-chart {
233233
background: white;
234234
overflow: hidden;
235+
236+
svg:active,
237+
.grabbing {
238+
cursor: grabbing !important;
239+
}
235240
}
236241

237242
.heatmap-node {
@@ -255,7 +260,7 @@ g.edge>text {
255260
.heatmap-tooltip {
256261
position: absolute;
257262
pointer-events: none;
258-
background: rgba(0,0,0,0.85);
263+
background: rgba(0, 0, 0, 0.85);
259264
color: white;
260265
padding: 6px 8px;
261266
border-radius: 4px;

lisa/lisa-analyses/imp-testcases/visualization/all-flame/flamegraph.html

Lines changed: 111 additions & 4 deletions
Large diffs are not rendered by default.

lisa/lisa-analyses/imp-testcases/visualization/analysis-flame/assets/style.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,11 @@ g.edge>text {
232232
#heatmap-chart {
233233
background: white;
234234
overflow: hidden;
235+
236+
svg:active,
237+
.grabbing {
238+
cursor: grabbing !important;
239+
}
235240
}
236241

237242
.heatmap-node {
@@ -255,7 +260,7 @@ g.edge>text {
255260
.heatmap-tooltip {
256261
position: absolute;
257262
pointer-events: none;
258-
background: rgba(0,0,0,0.85);
263+
background: rgba(0, 0, 0, 0.85);
259264
color: white;
260265
padding: 6px 8px;
261266
border-radius: 4px;

lisa/lisa-analyses/imp-testcases/visualization/analysis-flame/flamegraph.html

Lines changed: 111 additions & 4 deletions
Large diffs are not rendered by default.

lisa/lisa-analyses/imp-testcases/visualization/domain-flame/assets/style.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,11 @@ g.edge>text {
232232
#heatmap-chart {
233233
background: white;
234234
overflow: hidden;
235+
236+
svg:active,
237+
.grabbing {
238+
cursor: grabbing !important;
239+
}
235240
}
236241

237242
.heatmap-node {
@@ -255,7 +260,7 @@ g.edge>text {
255260
.heatmap-tooltip {
256261
position: absolute;
257262
pointer-events: none;
258-
background: rgba(0,0,0,0.85);
263+
background: rgba(0, 0, 0, 0.85);
259264
color: white;
260265
padding: 6px 8px;
261266
border-radius: 4px;

lisa/lisa-analyses/imp-testcases/visualization/domain-flame/flamegraph.html

Lines changed: 111 additions & 4 deletions
Large diffs are not rendered by default.

lisa/lisa-analyses/imp-testcases/visualization/fix-flame/assets/style.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,11 @@ g.edge>text {
232232
#heatmap-chart {
233233
background: white;
234234
overflow: hidden;
235+
236+
svg:active,
237+
.grabbing {
238+
cursor: grabbing !important;
239+
}
235240
}
236241

237242
.heatmap-node {
@@ -255,7 +260,7 @@ g.edge>text {
255260
.heatmap-tooltip {
256261
position: absolute;
257262
pointer-events: none;
258-
background: rgba(0,0,0,0.85);
263+
background: rgba(0, 0, 0, 0.85);
259264
color: white;
260265
padding: 6px 8px;
261266
border-radius: 4px;

lisa/lisa-analyses/imp-testcases/visualization/fix-flame/flamegraph.html

Lines changed: 111 additions & 4 deletions
Large diffs are not rendered by default.

lisa/lisa-analyses/imp-testcases/visualization/interproc-flame/assets/style.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,11 @@ g.edge>text {
232232
#heatmap-chart {
233233
background: white;
234234
overflow: hidden;
235+
236+
svg:active,
237+
.grabbing {
238+
cursor: grabbing !important;
239+
}
235240
}
236241

237242
.heatmap-node {
@@ -255,7 +260,7 @@ g.edge>text {
255260
.heatmap-tooltip {
256261
position: absolute;
257262
pointer-events: none;
258-
background: rgba(0,0,0,0.85);
263+
background: rgba(0, 0, 0, 0.85);
259264
color: white;
260265
padding: 6px 8px;
261266
border-radius: 4px;

lisa/lisa-analyses/imp-testcases/visualization/interproc-flame/flamegraph.html

Lines changed: 111 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ <h1>Analysis Flame Graph</h1>
3939
</div>
4040
<script>
4141
/*<![CDATA[*/
42-
const graph = "{\"children\":[{\"children\":[{\"children\":[{\"children\":[],\"end_ns\":\"56541156\",\"start_ns\":\"54031060\",\"text\":\"Fixpoint of untyped A::A(A*)\"},{\"children\":[],\"end_ns\":\"78792442\",\"start_ns\":\"59395736\",\"text\":\"Fixpoint of untyped A::getOne(A*)\"},{\"children\":[],\"end_ns\":\"83536163\",\"start_ns\":\"80910418\",\"text\":\"Fixpoint of untyped A::getPositive(A*, untyped)\"},{\"children\":[],\"end_ns\":\"86634077\",\"start_ns\":\"86137313\",\"text\":\"Fixpoint of untyped A::identity(A*, untyped)\"},{\"children\":[],\"end_ns\":\"89445291\",\"start_ns\":\"88894394\",\"text\":\"Fixpoint of untyped A::identity(A*, untyped)\"},{\"children\":[{\"children\":[],\"end_ns\":\"94057875\",\"start_ns\":\"93473532\",\"text\":\"Fixpoint of untyped A::identity(A*, untyped)\"}],\"end_ns\":\"94559016\",\"start_ns\":\"91976702\",\"text\":\"Fixpoint of untyped tests::helper(tests*, untyped, untyped)\"}],\"end_ns\":\"95364199\",\"start_ns\":\"26833881\",\"text\":\"Fixpoint of untyped tests::main(tests*)\"}],\"end_ns\":\"96742977\",\"start_ns\":\"758152\",\"text\":\"Program-wide fixpoint iteration 1\"}],\"end_ns\":\"96766546\",\"start_ns\":\"0\",\"text\":\"Program-wide fixpoint\"}";
42+
const graph = "{\"children\":[{\"children\":[{\"children\":[{\"children\":[],\"end_ns\":\"1039640\",\"start_ns\":\"821594\",\"text\":\"Fixpoint of untyped A::A(A*)\"},{\"children\":[],\"end_ns\":\"3015650\",\"start_ns\":\"1449466\",\"text\":\"Fixpoint of untyped A::getOne(A*)\"},{\"children\":[],\"end_ns\":\"4224275\",\"start_ns\":\"3509480\",\"text\":\"Fixpoint of untyped A::getPositive(A*, untyped)\"},{\"children\":[],\"end_ns\":\"5055759\",\"start_ns\":\"4886844\",\"text\":\"Fixpoint of untyped A::identity(A*, untyped)\"},{\"children\":[],\"end_ns\":\"5866845\",\"start_ns\":\"5697630\",\"text\":\"Fixpoint of untyped A::identity(A*, untyped)\"},{\"children\":[{\"children\":[],\"end_ns\":\"6984985\",\"start_ns\":\"6824538\",\"text\":\"Fixpoint of untyped A::identity(A*, untyped)\"}],\"end_ns\":\"7166236\",\"start_ns\":\"6423279\",\"text\":\"Fixpoint of untyped tests::helper(tests*, untyped, untyped)\"}],\"end_ns\":\"7387352\",\"start_ns\":\"348829\",\"text\":\"Fixpoint of untyped tests::main(tests*)\"}],\"end_ns\":\"7579549\",\"start_ns\":\"60282\",\"text\":\"Program-wide fixpoint iteration 1\"}],\"end_ns\":\"7586125\",\"start_ns\":\"0\",\"text\":\"Program-wide fixpoint\"}";
4343
/*]]>*/
4444

4545
// flatten tree
@@ -77,19 +77,126 @@ <h1>Analysis Flame Graph</h1>
7777
.range([0, width]);
7878

7979
// SVG & zoom
80+
const axisHeight = 24;
8081
const svg = d3.select("#heatmap-chart")
8182
.append("svg")
8283
.attr("width", width)
8384
.attr("height", height);
84-
const zoomLayer = svg.append("g");
85+
const zoomLayer = svg.append("g")
86+
.attr("transform", `translate(0, ${axisHeight})`);
87+
88+
// Add time axis at the top
89+
function formatTime(d) {
90+
// d is nanoseconds offset from minTime
91+
const ms = (d - minTime) / 1e6;
92+
if (ms < 1) return ((d - minTime) / 1e3).toFixed(0) + " μs";
93+
if (ms < 1000) return ms.toFixed(0) + " ms";
94+
const s = ms / 1000;
95+
if (s < 60) return s.toFixed(2) + " s";
96+
const m = Math.floor(s / 60);
97+
const sec = s % 60;
98+
if (m < 60) return `${m}m ${sec.toFixed(1)}s`;
99+
const h = Math.floor(m / 60);
100+
const min = m % 60;
101+
return `${h}h ${min}m`;
102+
}
103+
const axis = d3.axisTop(xScale)
104+
.ticks(Math.max(5, width / 180))
105+
.tickFormat(formatTime);
106+
// white background behind labels
107+
svg.append("rect")
108+
.attr("x", 0)
109+
.attr("y", 0)
110+
.attr("width", width)
111+
.attr("height", axisHeight)
112+
.attr("fill", "#fff")
113+
.attr("pointer-events", "none")
114+
.on("mousedown.zoomcursor", () => svg.classed("grabbing", true))
115+
.on("mouseup.zoomcursor", () => svg.classed("grabbing", false))
116+
.on("mouseleave.zoomcursor", () => svg.classed("grabbing", false));
117+
const axisGroup = svg.append("g")
118+
.attr("transform", `translate(0,${axisHeight})`)
119+
.call(axis);
120+
// Add vertical grid lines
121+
function drawGridLines(currentScale) {
122+
// Remove old grid lines
123+
axisGroup.selectAll(".grid-line").remove();
124+
// Add new grid lines for each tick
125+
axisGroup.selectAll(".tick").each(function (d) {
126+
axisGroup.append("line")
127+
.attr("class", "grid-line")
128+
.attr("x1", currentScale(d))
129+
.attr("x2", currentScale(d))
130+
.attr("y1", 0)
131+
.attr("y2", height)
132+
.attr("stroke", "#ccc")
133+
.attr("stroke-width", 1)
134+
.attr("pointer-events", "none");
135+
});
136+
}
137+
drawGridLines(xScale);
138+
85139
const zoom = d3.zoom()
86-
.scaleExtent([0.1, 50])
140+
.scaleExtent([1, 100])
87141
.on("zoom", (event) => {
88-
zoomLayer.attr("transform", event.transform);
142+
const t = event.transform;
143+
const scale = t.k;
144+
145+
const maxX = 0;
146+
const maxY = 0;
147+
const minX = Math.min(width - width * scale, 0);
148+
const minY = Math.min(height - height * scale, 0);
149+
const clampedX = Math.max(Math.min(t.x, maxX), minX);
150+
const clampedY = Math.max(Math.min(t.y, maxY), minY);
151+
152+
let clamped = false;
153+
if (t.x !== clampedX || t.y !== clampedY) clamped = true;
154+
155+
zoomLayer.attr("transform", `translate(${clampedX},${clampedY + axisHeight}) scale(${scale})`);
89156
updateLabels();
157+
158+
const newTransform = d3.zoomIdentity.translate(clampedX, 0).scale(scale);
159+
const newX = newTransform.rescaleX(xScale);
160+
// Clamp the axis domain to [minTime, maxTime]
161+
const domain = newX.domain();
162+
if (domain[0] < minTime || domain[1] > maxTime) {
163+
// If out of bounds, reset axis to [minTime, maxTime]
164+
axisGroup.call(axis.scale(xScale));
165+
drawGridLines(xScale);
166+
} else {
167+
axisGroup.call(axis.scale(newX));
168+
drawGridLines(newX);
169+
}
170+
171+
if (clamped) {
172+
svg.call(zoom.transform, d3.zoomIdentity.translate(clampedX, clampedY).scale(scale));
173+
}
90174
});
91175
svg.call(zoom);
92176

177+
// Disable default wheel zoom
178+
svg.on("wheel.zoom", null);
179+
180+
// Custom wheel handler
181+
svg.on("wheel.custom", function (event) {
182+
event.preventDefault();
183+
if (event.ctrlKey) {
184+
// Zoom (scale) when Ctrl is held
185+
d3.select(this).call(
186+
zoom.scaleBy,
187+
event.deltaY < 0 ? 1.1 : 1 / 1.1,
188+
[event.offsetX, event.offsetY]
189+
);
190+
} else {
191+
// Pan when Ctrl is not held
192+
d3.select(this).call(
193+
zoom.translateBy,
194+
-event.deltaX,
195+
-event.deltaY
196+
);
197+
}
198+
});
199+
93200
// draw nodes
94201
const tooltip = d3.select("#heatmap-tooltip");
95202
function showTooltip(event, d) {

0 commit comments

Comments
 (0)