Sha256: 35c49d017643e1d0228e07020af000334db02cb434e15e5510415a967f6635d5

Contents?: true

Size: 841 Bytes

Versions: 1

Compression:

Stored size: 841 Bytes

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(26) 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, :ascci => true) { |index,hex,print| }
  end

  b.report('hexdump ascii=true') do
    Hexdump.dump(DATA, :ascci => true, :output => OUTPUT)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hexdump-0.1.0 benchmarks/hexdump.rb