Permalink
Fetching contributors…
Cannot retrieve contributors at this time
22 lines (16 sloc) 410 Bytes
#!/usr/bin/env ruby
# text extraction is a handy benchmark of parsing/lexing performance, as
# the full content stream of each page is processed.
#
# run like so:
#
# ruby -Ilib tools/page_bench foo.pdf
require 'rubygems'
require 'pdf/reader'
reader = PDF::Reader.new(ARGV[0])
require "benchmark"
Benchmark.bm(1) do |x|
reader.pages.each do |page|
x.report(page.number) { page.text }
end
end