Created
August 9, 2016 15:23
-
-
Save jrunning/ca8de6889969e30ca8b08f4f4ab7d5c8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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