Add script/rubyprof to generate cachegrind callgraphs

This commit is contained in:
Florian Weingarten 2015-05-10 02:30:43 +00:00
parent 015e9570cd
commit 56c38f87b2
2 changed files with 19 additions and 0 deletions

View File

@ -28,6 +28,7 @@ gem 'test-unit' if RUBY_PLATFORM =~ /cygwin/ || RUBY_VERSION.start_with?("2.2")
gem 'rspec-mocks'
if ENV['BENCHMARK']
gem 'ruby-prof'
gem 'rbtrace'
gem 'stackprof'
gem 'benchmark-ips'

18
script/rubyprof Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env bash
export BENCHMARK=1
TEST_SCRIPT="Jekyll::Commands::Build.process({'source' => 'site', 'full_rebuild' => true})"
RUBY=$(cat <<RUBY
require 'ruby-prof'
result = RubyProf.profile{ ${TEST_SCRIPT} }
printer = RubyProf::CallTreePrinter.new(result)
filename = "tmp/ruby_prof_#{rand 10000}"
puts "Writing profile to #{filename}"
file = File.open(filename, "w")
printer.print(file, {})
file.close
RUBY
)
bundle exec ruby -r ./lib/jekyll -e "${RUBY}"