Skip to content

Commit

Permalink
add a handy tool for benchmarking the parsing of individual pages
Browse files Browse the repository at this point in the history
  • Loading branch information
yob committed Aug 5, 2012
1 parent 41f52ec commit 8468d71
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tools/page_bench
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/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

0 comments on commit 8468d71

Please sign in to comment.