Created
October 4, 2010 15:22
-
-
Save miloops/609862 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 'rubygems' | |
require 'barby' | |
require 'barby/outputter/cairo_outputter' | |
require 'rbench' | |
dimensions = {:height => 70, :margin => 10} | |
barcode = Barby::Code128C.new('081300010000102771000000000000500000000084') | |
TIMES = 1000 | |
puts Benchmark.measure { | |
TIMES.times do | |
File.open('cairo.png', 'w') {|f| | |
f.write barcode.to_png(dimensions) | |
} | |
end | |
} | |
require "./chunky_png_outputter" | |
puts Benchmark.measure { | |
TIMES.times do | |
File.open('chunky.png', 'w'){|f| | |
f.write barcode.to_canvas(dimensions).to_datastream | |
} | |
end | |
} | |
$ ruby cairo.rb | |
/Users/miloops/.rvm/gems/ruby-1.9.2-p0/gems/rbench-0.2.3/lib/rbench/group.rb:4: warning: undefining `object_id' may cause serious problems | |
/Users/miloops/.rvm/gems/ruby-1.9.2-p0/gems/rbench-0.2.3/lib/rbench/report.rb:4: warning: undefining `object_id' may cause serious problems | |
4.560000 0.200000 4.760000 ( 5.734010) | |
63.490000 0.530000 64.020000 ( 70.310717) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment