use strict; use warnings; use PDF::API2; use CAM::PDF; use Benchmark 'cmpthese'; my $fn = 'test.pdf'; my $str = do { local ( @ARGV, $/ ) = $fn; <> }; cmpthese -1, { 'PDF::API2' => sub { PDF::API2-> from_string( $str )-> page_count }, 'CAM::PDF' => sub { CAM::PDF-> new( $str )-> numPages }, 'CAM::PDF+' => sub { my $d = CAM::PDF-> new( $str ); $d-> cacheObjects; $d-> numPages }, }; __END__ Rate PDF::API2 CAM::PDF+ CAM::PDF PDF::API2 163/s -- -74% -95% CAM::PDF+ 614/s 277% -- -83% CAM::PDF 3586/s 2106% 484% --