Skip to content

Instantly share code, notes, and snippets.

@jrunning
Created August 9, 2016 15:23
Show Gist options
  • Save jrunning/ca8de6889969e30ca8b08f4f4ab7d5c8 to your computer and use it in GitHub Desktop.
Save jrunning/ca8de6889969e30ca8b08f4f4ab7d5c8 to your computer and use it in GitHub Desktop.
require "barby/barcode/code_128"
require "barby/outputter/png_outputter"
require "benchmark/ips"
require "tempfile"
dir = Dir.tmpdir
Benchmark.ips do |x|
x.report {
barcode = Barby::Code128B.new(rand(1000000000001..1000000001000))
Tempfile.open("barcode") do |f|
f.unlink
f.write barcode.to_png(height: 50, xdim: 2, margin: 2)
end
}
end
$ ruby 01-barby-benchmark.rb
Warming up --------------------------------------
11.000 i/100ms
Calculating -------------------------------------
116.482 (± 6.0%) i/s - 583.000 in 5.023950s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment