forked from yob/pdf-reader
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add a handy tool for benchmarking the parsing of individual pages
- Loading branch information
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
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
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 |