Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ test/tmp
test/version_tmp
tmp
*.swp
demo/graph.html
demo/graph*.html
demo/data.json
tags
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ gemspec

# both are optional, depending on platform
gem 'fast_stack'
gem 'stackprof', platform: [:mri_21, :mri_22, :mri_23]
gem 'stackprof', platform: [:mri_21, :mri_22, :mri_23, :mri_24]

8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ http://samsaffron.github.io/flamegraph/rails-startup.html

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
3. Make your changes
4. Run the tests (`bundle exec ruby -Ilib:test -e 'ARGV.each { |f| require f }' ./test/test*.rb`)
5. Commit your changes (`git commit -am 'Add some feature'`)
6. Push to the branch (`git push origin my-new-feature`)
7. Create new Pull Request
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,18 @@ <h3>Frame Info</h3>
</div>
<script>

var data = /**DATA**/;
var data = null;
<% if ENV['TEST'] %>
$.ajax({
url: './<%= ENV['FILE'] || 'data.json' %>',
async: false,
success: function(response) {
data = JSON.parse(response);
}
});
<% else %>
data = /**DATA**/;
<% end %>
var maxX = 0;
var maxY = 0;

Expand Down
3 changes: 2 additions & 1 deletion lib/flamegraph/renderer.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# inspired by https://github.com/brendangregg/FlameGraph
require 'base64'
require 'erb'

class Flamegraph::Renderer
def initialize(stacks)
@stacks = stacks
end

def graph_html(embed_resources)
body = read('flamegraph.html')
body = ERB.new(read('flamegraph.html.erb')).result
body.sub! "/**INCLUDES**/",
if embed_resources
embed("jquery.min.js","d3.min.js","lodash.min.js")
Expand Down
3 changes: 1 addition & 2 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'flamegraph'
require 'minitest/autorun'
require 'minitest/pride'