Skip to content

Instantly share code, notes, and snippets.

@sneakers-the-rat
Created October 5, 2021 20:59
Show Gist options
  • Save sneakers-the-rat/a287e0348645c1f1254f0acae2ac3719 to your computer and use it in GitHub Desktop.
Save sneakers-the-rat/a287e0348645c1f1254f0acae2ac3719 to your computer and use it in GitHub Desktop.
Profile Jekyll Build with ruby-prof
require "jekyll"
require "ruby-prof"
result = RubyProf.profile do
# you can set any of the --options you'd pass to build here
# it will automatically pick up the _config.yml file in source
options = {
"source" => './',
"destination" => './_site',
"watch" => true,
"verbose" => true
}
# with watch on, just ctrl+c to cancel the watch and safe profiling results
Jekyll::Commands::Build.process(options)
end
# three forms of profiles! see the ruby-prof docs for details
# https://ruby-prof.github.io/#reports
stack_printer = RubyProf::CallStackPrinter.new(result)
flat_printer = RubyProf::FlatPrinter.new(result)
graph_printer = RubyProf::GraphHtmlPrinter.new(result)
File.open("_profile_stack.html", 'w') { |file| stack_printer.print(file) }
File.open("_profile_flat.txt", 'w') { |file| flat_printer.print(file) }
File.open("_profile_graph.html", 'w') { |file| graph_printer.print(file) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment