forked from prawnpdf/prawn
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtable_bench.rb
42 lines (32 loc) · 1017 Bytes
/
table_bench.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# encoding: utf-8
require "benchmark"
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require "prawn"
csv_data = nil
ruby_18 do
require "rubygems"
require "fastercsv"
csv_data = FasterCSV.read("#{Prawn::BASEDIR}/examples/table/currency.csv") *
(ARGV.first || 1).to_i
end
ruby_19 do
require "csv"
csv_data = CSV.read("#{Prawn::BASEDIR}/examples/table/currency.csv") *
(ARGV.first || 1).to_i
end
doc = Prawn::Document.new
#######################
# Benchmarking code #
#######################
puts "Processing #{csv_data.length} records"
Benchmark.bmbm do |x|
x.report("Prawn") do
doc.table(csv_data, :font_size => 10,
:vertical_padding => 2,
:horizontal_padding => 5,
:position => :center,
:row_colors => :pdf_writer,
:headers => ["Date","Rate"])
doc.render_file('currency_prawn.pdf')
end
end