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 12 $| = 1;
13 13  
14 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 17 my @tests = (
16 18 ['no arguments', []],
17 19 ['generate object streams', ['--object-streams=generate']],
... ... @@ -20,6 +22,7 @@ my @tests = (
20 22 ['shared resource check', ['--split-pages', '--remove-unreferenced-resources=auto']],
21 23 ['linearize', ['--linearize']],
22 24 ['encrypt', ['--encrypt', 'u', 'o', '256', '--']],
  25 + ['extract first page', ['--empty', '--pages', '<IN>', '1', '--']],
23 26 ['json-output', ['--json-output']],
24 27 ['json-input', ['--json-input']],
25 28 );
... ... @@ -214,7 +217,7 @@ sub filter_args
214 217 {
215 218 my $to_check = $arg;
216 219 $to_check =~ s/=.*$//;
217   - if (index($help, $to_check) == -1)
  220 + if (($to_check =~ m/^-/) && (index($help, $to_check) == -1))
218 221 {
219 222 my $new_arg = $arg_compat{$arg};
220 223 if (! defined $new_arg)
... ... @@ -287,15 +290,27 @@ sub run_test
287 290 my ($file, $args) = @_;
288 291  
289 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 298 if ($arg eq '--json-output')
293 299 {
294 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 314 # Run once and discard to update caches
300 315 system("sync");
301 316 run_cmd(@cmd);
... ...