Sha256: 1ca680674a4d04db789a1acdef76b549b9e177b6e237e23b34907007e3098866
Contents?: true
Size: 859 Bytes
Versions: 3
Compression:
Stored size: 859 Bytes
Contents
# frozen_string_literal: true 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_pygments.rb').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 ') { (1..num).each { |_i|; Pygments.highlight(code, lexer: 'python'); } } x.report('pygments popen (process already started) ') { (1..num).each { |_i|; Pygments.highlight(code, lexer: 'python'); } } x.report('pygments popen (process already started 2) ') { (1..num).each { |_i|; Pygments.highlight(code, lexer: 'python'); } } end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pygments.rb-2.0.0 | bench.rb |
pygments.rb-2.0.0.rc3 | bench.rb |
pygments.rb-2.0.0.rc2 | bench.rb |