Skip to content

Instantly share code, notes, and snippets.

@mame
Created September 16, 2019 10:48
Show Gist options
  • Save mame/c6df4ca67f9422d9956e2f64e2f45d98 to your computer and use it in GitHub Desktop.
Save mame/c6df4ca67f9422d9956e2f64e2f45d98 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/spiermar/[email protected]/dist/d3-flamegraph.css">
<style>
/* Space out content a bit */
body {
padding-top: 20px;
padding-bottom: 20px;
}
/* Custom page header */
.header {
padding-bottom: 20px;
padding-right: 15px;
padding-left: 15px;
border-bottom: 1px solid #e5e5e5;
}
/* Make the masthead heading the same height as the navigation */
.header h3 {
margin-top: 0;
margin-bottom: 0;
line-height: 40px;
}
/* Customize container */
.container {
max-width: 990px;
}
address {
text-align: right;
}
</style>
<title>stackprof (mode: cpu)</title>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<div class="header clearfix">
<nav>
<div class="pull-right">
<form class="form-inline" id="form">
<a class="btn" href="javascript: resetZoom();">Reset zoom</a>
<a class="btn" href="javascript: clear();">Clear</a>
<div class="form-group">
<input type="text" class="form-control" id="term">
</div>
<a class="btn btn-primary" href="javascript: search();">Search</a>
</form>
</div>
</nav>
<h3 class="text-muted">stackprof (mode: cpu)</h3>
</div>
<div id="chart">
</div>
<address>
powered by <a href="https://github.com/spiermar/d3-flame-graph">d3-flame-graph</a>
</address>
<hr>
<div id="details">
</div>
</div>
<!-- D3.js -->
<script src="https://d3js.org/d3.v4.min.js" charset="utf-8"></script>
<!-- d3-tip -->
<script type="text/javascript" src=https://cdnjs.cloudflare.com/ajax/libs/d3-tip/0.9.1/d3-tip.min.js></script>
<!-- d3-flamegraph -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/spiermar/[email protected]/dist/d3-flamegraph.min.js"></script>
<script type="text/javascript">
var flameGraph = d3.flamegraph()
.width(960)
.cellHeight(18)
.transitionDuration(750)
.minFrameSize(5)
.transitionEase(d3.easeCubic)
.sort(true)
//Example to sort in reverse order
//.sort(function(a,b){ return d3.descending(a.name, b.name);})
.title("")
.onClick(onClick)
.differential(false)
.selfValue(false);
// Example on how to use custom tooltips using d3-tip.
// var tip = d3.tip()
// .direction("s")
// .offset([8, 0])
// .attr('class', 'd3-flame-graph-tip')
// .html(function(d) { return "name: " + d.data.name + ", value: " + d.data.value; });
// flameGraph.tooltip(tip);
var details = document.getElementById("details");
flameGraph.setDetailsElement(details);
// Example on how to use custom labels
// var label = function(d) {
// return "name: " + d.name + ", value: " + d.value;
// }
// flameGraph.label(label);
// Example of how to set fixed chart height
// flameGraph.height(540);
d3.select("#chart")
.datum({"name":"<root>","value":977,"children":[{"name":"<main> : bin/optcarrot-bench","value":181,"children":[{"name":"<main> : /home/mame/work/optcarrot/bin/optcarrot-bench","value":181,"children":[{"name":"Optcarrot::NES#run : /home/mame/work/optcarrot/lib/optcarrot/nes.rb","value":181,"children":[{"name":"Optcarrot::NES#step : /home/mame/work/optcarrot/lib/optcarrot/nes.rb","value":181,"children":[{"name":"Optcarrot::CPU#run : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":161,"children":[{"name":"Optcarrot::CPU#fetch : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":15,"children":[]},{"name":"Optcarrot::CPU#do_clock : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":6,"children":[{"name":"Optcarrot::APU#do_clock : /home/mame/work/optcarrot/lib/optcarrot/apu.rb","value":6,"children":[{"name":"Optcarrot::CPU#current_clock : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":4,"children":[]},{"name":"Optcarrot::APU#clock_dma : /home/mame/work/optcarrot/lib/optcarrot/apu.rb","value":2,"children":[{"name":"Optcarrot::APU#clock_dmc : /home/mame/work/optcarrot/lib/optcarrot/apu.rb","value":2,"children":[{"name":"Optcarrot::APU#update : /home/mame/work/optcarrot/lib/optcarrot/apu.rb","value":1,"children":[{"name":"Optcarrot::APU#proceed : /home/mame/work/optcarrot/lib/optcarrot/apu.rb","value":1,"children":[{"name":"Optcarrot::APU::Mixer#sample : /home/mame/work/optcarrot/lib/optcarrot/apu.rb","value":1,"children":[{"name":"Optcarrot::APU::Noise#sample : /home/mame/work/optcarrot/lib/optcarrot/apu.rb","value":1,"children":[]}]}]}]}]}]}]}]},{"name":"Optcarrot::CPU#rw_op : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":4,"children":[{"name":"Optcarrot::CPU#store_zpg : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":2,"children":[]},{"name":"Optcarrot::CPU#zpg : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":2,"children":[{"name":"Optcarrot::CPU#fetch : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":2,"children":[]}]}]},{"name":"Optcarrot::CPU#w_op : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":4,"children":[{"name":"Optcarrot::CPU#store_mem : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":2,"children":[{"name":"Optcarrot::CPU#store : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":2,"children":[{"name":"Optcarrot::APU::Pulse#poke_0 : /home/mame/work/optcarrot/lib/optcarrot/apu.rb","value":1,"children":[{"name":"Optcarrot::APU::Oscillator#poke_0 : /home/mame/work/optcarrot/lib/optcarrot/apu.rb","value":1,"children":[{"name":"Optcarrot::APU#update_latency : /home/mame/work/optcarrot/lib/optcarrot/apu.rb","value":1,"children":[{"name":"Optcarrot::APU#update : /home/mame/work/optcarrot/lib/optcarrot/apu.rb","value":1,"children":[{"name":"Optcarrot::APU#proceed : /home/mame/work/optcarrot/lib/optcarrot/apu.rb","value":1,"children":[{"name":"Optcarrot::APU::Mixer#sample : /home/mame/work/optcarrot/lib/optcarrot/apu.rb","value":1,"children":[{"name":"Optcarrot::APU::DMC#sample : /home/mame/work/optcarrot/lib/optcarrot/apu.rb","value":1,"children":[]}]}]}]}]}]}]},{"name":"Optcarrot::PPU#poke_2007 : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":1,"children":[{"name":"Optcarrot::PPU#poke_2007 : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":1,"children":[]}]}]}]},{"name":"Optcarrot::CPU#_sta : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":1,"children":[]},{"name":"Optcarrot::CPU#abs : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":1,"children":[{"name":"Optcarrot::CPU#peek16 : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":1,"children":[]}]}]},{"name":"Optcarrot::CPU#r_op : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":74,"children":[{"name":"Optcarrot::CPU#imm : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":1,"children":[]},{"name":"Optcarrot::CPU#zpg : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":48,"children":[{"name":"Optcarrot::CPU#fetch : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":38,"children":[]}]},{"name":"Optcarrot::CPU#_cmp : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":15,"children":[]},{"name":"Optcarrot::CPU#_adc : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":1,"children":[]},{"name":"Optcarrot::CPU#_ldy : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":1,"children":[]},{"name":"Optcarrot::CPU#abs_x : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":3,"children":[{"name":"Optcarrot::CPU#abs_reg : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":3,"children":[{"name":"Optcarrot::CPU#fetch : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":2,"children":[]}]}]},{"name":"Optcarrot::CPU#abs : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":5,"children":[{"name":"Optcarrot::CPU#peek16 : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":1,"children":[]},{"name":"Optcarrot::CPU#read_write : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":4,"children":[{"name":"Optcarrot::CPU#fetch : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":4,"children":[{"name":"Optcarrot::Pads#peek_401x : /home/mame/work/optcarrot/lib/optcarrot/pad.rb","value":1,"children":[{"name":"Optcarrot::CPU#update : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":1,"children":[{"name":"Optcarrot::APU#clock_dma : /home/mame/work/optcarrot/lib/optcarrot/apu.rb","value":1,"children":[]}]}]},{"name":"Optcarrot::PPU#peek_2002 : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":3,"children":[{"name":"Optcarrot::PPU#update : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":3,"children":[{"name":"Optcarrot::PPU#sync : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":3,"children":[{"name":"Optcarrot::PPU#run : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":3,"children":[]}]}]}]}]}]}]}]},{"name":"Optcarrot::CPU#_beq : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":43,"children":[{"name":"Optcarrot::CPU#branch : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":42,"children":[{"name":"Optcarrot::CPU#fetch : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":29,"children":[]}]}]},{"name":"Optcarrot::CPU#_bne : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":2,"children":[{"name":"Optcarrot::CPU#branch : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":1,"children":[{"name":"Optcarrot::CPU#fetch : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":1,"children":[]}]}]},{"name":"Optcarrot::CPU#_txa : /home/mame/work/optcarrot/lib/optcarrot/cpu.rb","value":1,"children":[]}]},{"name":"Optcarrot::APU#vsync : /home/mame/work/optcarrot/lib/optcarrot/apu.rb","value":19,"children":[{"name":"Optcarrot::APU#flush_sound : /home/mame/work/optcarrot/lib/optcarrot/apu.rb","value":19,"children":[{"name":"Optcarrot::APU#proceed : /home/mame/work/optcarrot/lib/optcarrot/apu.rb","value":19,"children":[{"name":"Optcarrot::APU::Mixer#sample : /home/mame/work/optcarrot/lib/optcarrot/apu.rb","value":17,"children":[{"name":"Optcarrot::APU::Triangle#sample : /home/mame/work/optcarrot/lib/optcarrot/apu.rb","value":2,"children":[]},{"name":"Optcarrot::APU::Pulse#sample : /home/mame/work/optcarrot/lib/optcarrot/apu.rb","value":1,"children":[]},{"name":"Optcarrot::APU::DMC#sample : /home/mame/work/optcarrot/lib/optcarrot/apu.rb","value":2,"children":[]},{"name":"Optcarrot::APU::Noise#sample : /home/mame/work/optcarrot/lib/optcarrot/apu.rb","value":9,"children":[]}]}]}]}]},{"name":"Optcarrot::PPU#vsync : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":1,"children":[{"name":"Optcarrot::PPU#run : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":1,"children":[{"name":"Optcarrot::PPU#make_sure_invariants : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":1,"children":[]}]}]}]}]}]}]},{"name":"Optcarrot::PPU#run : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":796,"children":[{"name":"Optcarrot::PPU#main_loop : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":796,"children":[{"name":"Optcarrot::PPU#main_loop : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":765,"children":[{"name":"Optcarrot::PPU#wait_two_clocks : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":8,"children":[]},{"name":"Optcarrot::PPU#wait_one_clock : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":107,"children":[]},{"name":"Optcarrot::PPU#update_enabled_flags : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":17,"children":[]},{"name":"Optcarrot::PPU#batch_render_eight_pixels : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":10,"children":[]},{"name":"Optcarrot::PPU#render_pixel : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":209,"children":[]},{"name":"Optcarrot::PPU#evaluate_sprites_odd : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":73,"children":[{"name":"Optcarrot::PPU#evaluate_sprites_odd_phase_9 : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":11,"children":[]},{"name":"Optcarrot::PPU#evaluate_sprites_odd_phase_1 : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":32,"children":[]}]},{"name":"Optcarrot::PPU#evaluate_sprites_even : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":58,"children":[]},{"name":"Optcarrot::PPU#load_tiles : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":52,"children":[]},{"name":"Optcarrot::PPU#scroll_clock_x : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":18,"children":[]},{"name":"Optcarrot::PPU#fetch_bg_pattern_1 : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":14,"children":[]},{"name":"Optcarrot::PPU#fetch_bg_pattern_0 : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":20,"children":[]},{"name":"Optcarrot::PPU#fetch_attr : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":13,"children":[]},{"name":"Optcarrot::PPU#open_attr : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":33,"children":[{"name":"Optcarrot::PPU#update_address_line : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":27,"children":[]}]},{"name":"Optcarrot::PPU#fetch_name : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":26,"children":[]},{"name":"Optcarrot::PPU#open_name : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":27,"children":[{"name":"Optcarrot::PPU#update_address_line : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":11,"children":[]}]},{"name":"Optcarrot::PPU#open_pattern : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":43,"children":[{"name":"Optcarrot::PPU#update_address_line : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":17,"children":[]}]}]},{"name":"Optcarrot::PPU#wait_one_clock : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":11,"children":[]},{"name":"Optcarrot::PPU#update_enabled_flags_edge : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":1,"children":[]},{"name":"Optcarrot::PPU#preload_tiles : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":4,"children":[]},{"name":"Optcarrot::PPU#fetch_bg_pattern_0 : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":2,"children":[]},{"name":"Optcarrot::PPU#fetch_attr : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":2,"children":[]},{"name":"Optcarrot::PPU#open_attr : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":1,"children":[]},{"name":"Optcarrot::PPU#fetch_name : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":1,"children":[]},{"name":"Optcarrot::PPU#open_name : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":4,"children":[{"name":"Optcarrot::PPU#update_address_line : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":2,"children":[]}]},{"name":"Optcarrot::PPU#open_pattern : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":3,"children":[{"name":"Optcarrot::PPU#update_address_line : /home/mame/work/optcarrot/lib/optcarrot/ppu.rb","value":1,"children":[]}]}]}]}]})
.call(flameGraph);
document.getElementById("form").addEventListener("submit", function(event){
event.preventDefault();
search();
});
function search() {
var term = document.getElementById("term").value;
flameGraph.search(term);
}
function clear() {
document.getElementById('term').value = '';
flameGraph.clear();
}
function resetZoom() {
flameGraph.resetZoom();
}
function onClick(d) {
console.info("Clicked on " + d.data.name);
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment