Sha256: f9cbd5c5b03ba81138df138ddedd89a2346ed34435734fceac22dcd309fb0fe5

Contents?: true

Size: 825 Bytes

Versions: 33

Compression:

Stored size: 825 Bytes

Contents

require File.join(File.dirname(__FILE__), '/lib/pygments.rb')
require 'benchmark'

include Benchmark
# number of iterations
num = ARGV[0] ? ARGV[0].to_i : 10

# we can also repeat the code itself
repeats = ARGV[1] ? ARGV[1].to_i : 1

code = File.open('test/test_data.py').read.to_s * repeats

puts "Benchmarking....\n"
puts "Size: " + code.bytesize.to_s + " bytes\n"
puts "Iterations: " + num.to_s + "\n"

Benchmark.bm(40) do |x|
  x.report("pygments popen                             ")  { for i in 1..num; Pygments.highlight(code, :lexer => 'python'); end }
  x.report("pygments popen (process already started)   ")  { for i in 1..num; Pygments.highlight(code, :lexer => 'python'); end }
  x.report("pygments popen (process already started 2) ")  { for i in 1..num; Pygments.highlight(code, :lexer => 'python'); end }
end

Version data entries

33 entries across 33 versions & 5 rubygems

Version Path
pygments.rb-1.2.1 bench.rb
pygments.rb-1.2.0 bench.rb
pygments.rb-1.1.2 bench.rb
pygments.rb-1.1.1 bench.rb
pygments.rb-1.1.0 bench.rb
pygments.rb-1.0.0 bench.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/pygments.rb-0.6.3/bench.rb
pygments.rb-0.6.3 bench.rb
pygments.rb-0.6.2 bench.rb
pygments.rb-0.6.1 bench.rb
pygments.rb-0.6.0 bench.rb
mortar-pygments.rb-0.5.7 bench.rb
mortar-pygments.rb-0.5.6 bench.rb
mortar-pygments.rb-0.5.5 bench.rb
pygments.rb-jruby-0.5.4.2 bench.rb
pygments.rb-jruby-0.5.4.1 bench.rb
pygments.rb-jruby-0.5.4 bench.rb
gitlab-pygments.rb-0.5.4 bench.rb
pygments.rb-0.5.4 bench.rb
pygments.rb-0.5.2 bench.rb