Skip to content

Instantly share code, notes, and snippets.

@marekjelen
Created February 21, 2012 15:16
Show Gist options
  • Save marekjelen/1876985 to your computer and use it in GitHub Desktop.
Save marekjelen/1876985 to your computer and use it in GitHub Desktop.
Pygments for Ruby (benchmark)
require 'pygmentize'
require 'pygments.rb'
code = <<EOF
require 'sinatra'
get '/hi' do
"Hello World!"
end
EOF
start = Time.now
100.times do
Pygmentize.process(code, :ruby)
end
puts Time.now - start
start = Time.now
100.times do
Pygments.highlight(code, :lexer => 'ruby')
end
puts Time.now - start
__END__
marek@homer ~ (ruby-1.9.3-p0) ∙ → ruby pyg.rb
21.000688
0.609097
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment