Sha256: d3f0bb10817734057ad37f9acb982f7476f676f8d6308ac7b01f4abf831d212e
Contents?: true
Size: 835 Bytes
Versions: 2
Compression:
Stored size: 835 Bytes
Contents
# frozen_string_literal: true require File.join(File.dirname(__FILE__), '/lib/pygments.rb') require '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.read('test/test_pygments.rb') * repeats puts "Benchmarking....\n" puts "Size: #{code.bytesize} bytes\n" puts "Iterations: #{num}\n" Benchmark.bm(40) do |x| x.report('pygments popen ') do (1..num).each { |_i|; Pygments.highlight(code, lexer: 'python'); } end x.report('pygments popen (process already started) ') do (1..num).each { |_i|; Pygments.highlight(code, lexer: 'python'); } end x.report('pygments popen (process already started 2) ') do (1..num).each { |_i|; Pygments.highlight(code, lexer: 'python'); } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pygments.rb-2.4.1 | bench.rb |
pygments.rb-2.4.0 | bench.rb |