Sha256: 2ca588962dcdcb16e5cb2348538c6db13cd078d381cd60c7c0325b39c5db44c6
Contents?: true
Size: 1.12 KB
Versions: 2
Compression:
Stored size: 1.12 KB
Contents
#!/usr/bin/env ruby $LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__),'..','lib')) require 'hexdump' require 'benchmark' DATA = ((0..255).map { |b| b.chr }.join) * 10000 OUTPUT = Class.new { def <<(data); end }.new Benchmark.bm(27) do |b| b.report('hexdump (block)') do Hexdump.dump(DATA) { |index,hex,print| } end b.report('hexdump') do Hexdump.dump(DATA, :output => OUTPUT) end b.report('hexdump width=256 (block)') do Hexdump.dump(DATA, :width => 256) { |index,hex,print| } end b.report('hexdump width=256') do Hexdump.dump(DATA, :width => 256, :output => OUTPUT) end b.report('hexdump ascii=true (block)') do Hexdump.dump(DATA, :ascii => true) { |index,hex,print| } end b.report('hexdump ascii=true') do Hexdump.dump(DATA, :ascii => true, :output => OUTPUT) end [2, 4, 8].each do |word_size| b.report("hexdump word_size=#{word_size} (block)") do Hexdump.dump(DATA, :word_size => word_size) { |index,hex,print| } end b.report("hexdump word_size=#{word_size}") do Hexdump.dump(DATA, :word_size => word_size, :output => OUTPUT) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hexdump-0.2.4 | benchmarks/hexdump.rb |
hexdump-0.2.3 | benchmarks/hexdump.rb |