Commit 3630a8c597a9abec853719b5cad176318a921bbf

Authored by Jay Berkenbilt
1 parent 562ff1b6

Performance check: add test for extraction of single page

It is common to just read a few objects. Checking extraction of the
first page exercises this to make sure we don't accidentally introduce
a change that makes that case worse, such as adding an unnecessary
traversal of the file, prematurely resolving objects we don't need,
etc.
Showing 1 changed file with 19 additions and 4 deletions
performance_check
@@ -12,6 +12,8 @@ my $whoami = basename($0); @@ -12,6 +12,8 @@ my $whoami = basename($0);
12 $| = 1; 12 $| = 1;
13 13
14 # [ name, [ args ] ] 14 # [ name, [ args ] ]
  15 +# If <IN> appears, it is replaced with the input file name. Otherwise,
  16 +# the input file name is added to the end of the arguments.
15 my @tests = ( 17 my @tests = (
16 ['no arguments', []], 18 ['no arguments', []],
17 ['generate object streams', ['--object-streams=generate']], 19 ['generate object streams', ['--object-streams=generate']],
@@ -20,6 +22,7 @@ my @tests = ( @@ -20,6 +22,7 @@ my @tests = (
20 ['shared resource check', ['--split-pages', '--remove-unreferenced-resources=auto']], 22 ['shared resource check', ['--split-pages', '--remove-unreferenced-resources=auto']],
21 ['linearize', ['--linearize']], 23 ['linearize', ['--linearize']],
22 ['encrypt', ['--encrypt', 'u', 'o', '256', '--']], 24 ['encrypt', ['--encrypt', 'u', 'o', '256', '--']],
  25 + ['extract first page', ['--empty', '--pages', '<IN>', '1', '--']],
23 ['json-output', ['--json-output']], 26 ['json-output', ['--json-output']],
24 ['json-input', ['--json-input']], 27 ['json-input', ['--json-input']],
25 ); 28 );
@@ -214,7 +217,7 @@ sub filter_args @@ -214,7 +217,7 @@ sub filter_args
214 { 217 {
215 my $to_check = $arg; 218 my $to_check = $arg;
216 $to_check =~ s/=.*$//; 219 $to_check =~ s/=.*$//;
217 - if (index($help, $to_check) == -1) 220 + if (($to_check =~ m/^-/) && (index($help, $to_check) == -1))
218 { 221 {
219 my $new_arg = $arg_compat{$arg}; 222 my $new_arg = $arg_compat{$arg};
220 if (! defined $new_arg) 223 if (! defined $new_arg)
@@ -287,15 +290,27 @@ sub run_test @@ -287,15 +290,27 @@ sub run_test
287 my ($file, $args) = @_; 290 my ($file, $args) = @_;
288 291
289 my $outfile = "out.pdf"; 292 my $outfile = "out.pdf";
290 - foreach my $arg (@$args) 293 + my $found_in = 0;
  294 + my @cmd = ($executable, @$report_mem);
  295 + for (@$args)
291 { 296 {
  297 + my $arg = $_;
292 if ($arg eq '--json-output') 298 if ($arg eq '--json-output')
293 { 299 {
294 $outfile = "out.json"; 300 $outfile = "out.json";
295 - last;  
296 } 301 }
  302 + elsif ($arg eq '<IN>')
  303 + {
  304 + $found_in = 1;
  305 + $arg = $file;
  306 + }
  307 + push(@cmd, $arg);
  308 + }
  309 + if (! $found_in)
  310 + {
  311 + push(@cmd, $file);
297 } 312 }
298 - my @cmd = ($executable, @$args, @$report_mem, $file, "$workdir/$outfile"); 313 + push(@cmd, "$workdir/$outfile");
299 # Run once and discard to update caches 314 # Run once and discard to update caches
300 system("sync"); 315 system("sync");
301 run_cmd(@cmd); 316 run_cmd(@cmd);