-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate flame chart for performance analysis #895
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
aa4cbb5
Add computation log test for forest case
fpagnoux f8ab588
Introduce performance log for time tracing
sandcha 95bb233
Handle recursive call for performance log children
sandcha 3ba8547
Use high precision timer for profiling
Morendil fc370b3
Add performance option to openfisca test command
sandcha 658fee8
Improve performance test case
sandcha ca702b8
Add tests for invocation of performance log
Morendil af8e34f
Move from performance print to json file
sandcha 81546ba
Add html file for performance flame graph
sandcha 059d778
Test index.html generation for performance analysis
sandcha 30d5673
Generate index.html alongside performance.json for easy viewing
Morendil 16798f0
Set internal method to private
sandcha b1f66f8
Delete performance files after test
sandcha 4f7c890
Remove code examples from chart html page
sandcha e4b060d
Enable full tracer to generate performance graph
sandcha 41b7424
Move html page to assets directory
sandcha 90333fb
Improve performance option description for openfisca test command
sandcha 00d17a7
Use variables for performance paths
sandcha 31dcc23
Explicit method names
fpagnoux 24e1bbe
Move time measurement logic to tracer
fpagnoux 961b901
Improve graph labels and title
fpagnoux d4e1c31
Simplify tracer interface
fpagnoux c18d61b
Set record_calculation_start/end helpers to private
sandcha aeb1a47
Use pythonic 'with' to open files
sandcha 193b7ef
Bump version number
sandcha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ dist/ | |
.noseids | ||
.pytest_cache | ||
.mypy_cache | ||
performance.json |
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
Empty file.
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,140 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<!-- source: https://github.com/spiermar/d3-flame-graph/blob/4603adf4a0ed788dc1d9d51e198bd5d21c48fd77/index.html --> | ||
<!-- BSD 3 Clause - Copyright Mike Bostock --> | ||
<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/d3-flame-graph@2.0.3/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; | ||
} | ||
</style> | ||
|
||
<title>Performance log</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">Performance log</h3> | ||
</div> | ||
<div id="chart"> | ||
</div> | ||
<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/d3-flame-graph@2.0.3/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) | ||
.title("") | ||
.onClick(onClick) | ||
.differential(false) | ||
.selfValue(false); | ||
|
||
var details = document.getElementById("details"); | ||
flameGraph.setDetailsElement(details); | ||
|
||
flameGraph.label(function(d) { | ||
var timeInSec = d.data.value.toPrecision(3) + "s" | ||
var label = d.data.name + ": " + timeInSec | ||
if (d.parent) { | ||
var percentageOfParent = (d.data.value / d.parent.value) * 100 | ||
label += " (" + percentageOfParent.toPrecision(3) + "%)" | ||
} | ||
return label | ||
}); | ||
|
||
d3.json("performance.json", function(error, data) { | ||
if (error) return console.warn(error); | ||
d3.select("#chart") | ||
.datum(data) | ||
.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> |
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😍