forked from bloomberg/memray
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
flamegraph: Bootstrap new temporal_flamegraph.html
Create a template page for a new type of flame graph. Initially this is just an exactly copy of our existing flame graph template, to make the changes from the original stand out as diffs in future commits. Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
- Loading branch information
Showing
5 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { debounced, initMemoryGraph, resizeMemoryGraph } from "./common"; | ||
|
||
import { | ||
initThreadsDropdown, | ||
drawChart, | ||
handleFragments, | ||
onFilterUninteresting, | ||
onFilterImportSystem, | ||
onFilterThread, | ||
onResetZoom, | ||
onResize, | ||
onInvert, | ||
getFlamegraph, | ||
} from "./flamegraph_common"; | ||
|
||
window.resizeMemoryGraph = resizeMemoryGraph; | ||
|
||
function packedDataToTree(packedData) { | ||
const { strings, nodes, unique_threads } = packedData; | ||
|
||
const node_objects = nodes.name.map((_, i) => ({ | ||
name: strings[nodes["name"][i]], | ||
location: [ | ||
strings[nodes["function"][i]], | ||
strings[nodes["filename"][i]], | ||
nodes["lineno"][i], | ||
], | ||
value: nodes["value"][i], | ||
children: nodes["children"][i], | ||
n_allocations: nodes["n_allocations"][i], | ||
thread_id: strings[nodes["thread_id"][i]], | ||
interesting: nodes["interesting"][i] !== 0, | ||
import_system: nodes["import_system"][i] !== 0, | ||
})); | ||
|
||
for (const node of node_objects) { | ||
node["children"] = node["children"].map((idx) => node_objects[idx]); | ||
} | ||
|
||
const root = node_objects[0]; | ||
root["unique_threads"] = unique_threads.map((tid) => strings[tid]); | ||
return root; | ||
} | ||
|
||
// Main entrypoint | ||
function main() { | ||
data = packedDataToTree(packed_data); | ||
initMemoryGraph(memory_records); | ||
initThreadsDropdown(data, merge_threads); | ||
|
||
// Create the flamegraph renderer | ||
drawChart(data); | ||
|
||
// Set zoom to correct element | ||
if (location.hash) { | ||
handleFragments(); | ||
} | ||
|
||
// Setup event handlers | ||
document.getElementById("invertButton").onclick = onInvert; | ||
document.getElementById("resetZoomButton").onclick = onResetZoom; | ||
document.getElementById("resetThreadFilterItem").onclick = onFilterThread; | ||
let hideUninterestingCheckBox = document.getElementById("hideUninteresting"); | ||
hideUninterestingCheckBox.onclick = onFilterUninteresting.bind(this); | ||
let hideImportSystemCheckBox = document.getElementById("hideImportSystem"); | ||
hideImportSystemCheckBox.onclick = onFilterImportSystem.bind(this); | ||
// Enable filtering by default | ||
onFilterUninteresting.bind(this)(); | ||
|
||
document.onkeyup = (event) => { | ||
if (event.code == "Escape") { | ||
onResetZoom(); | ||
} | ||
}; | ||
document.getElementById("searchTerm").addEventListener("input", () => { | ||
const termElement = document.getElementById("searchTerm"); | ||
getFlamegraph().search(termElement.value); | ||
}); | ||
|
||
window.addEventListener("popstate", handleFragments); | ||
window.addEventListener("resize", debounced(onResize)); | ||
|
||
// Enable tooltips | ||
$('[data-toggle-second="tooltip"]').tooltip(); | ||
$('[data-toggle="tooltip"]').tooltip(); | ||
} | ||
|
||
document.addEventListener("DOMContentLoaded", main); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{% extends "flamegraph.html" %} | ||
|
||
{% block flamegraph_script %} | ||
<script type="text/javascript"> | ||
{%- include "assets/temporal_flamegraph.js" -%} | ||
</script> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters