From 3630a8c597a9abec853719b5cad176318a921bbf Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Fri, 25 Nov 2022 13:16:00 -0500 Subject: [PATCH] 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. --- performance_check | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/performance_check b/performance_check index ac04d168..85ee658b 100755 --- a/performance_check +++ b/performance_check @@ -12,6 +12,8 @@ my $whoami = basename($0); $| = 1; # [ name, [ args ] ] +# If appears, it is replaced with the input file name. Otherwise, +# the input file name is added to the end of the arguments. my @tests = ( ['no arguments', []], ['generate object streams', ['--object-streams=generate']], @@ -20,6 +22,7 @@ my @tests = ( ['shared resource check', ['--split-pages', '--remove-unreferenced-resources=auto']], ['linearize', ['--linearize']], ['encrypt', ['--encrypt', 'u', 'o', '256', '--']], + ['extract first page', ['--empty', '--pages', '', '1', '--']], ['json-output', ['--json-output']], ['json-input', ['--json-input']], ); @@ -214,7 +217,7 @@ sub filter_args { my $to_check = $arg; $to_check =~ s/=.*$//; - if (index($help, $to_check) == -1) + if (($to_check =~ m/^-/) && (index($help, $to_check) == -1)) { my $new_arg = $arg_compat{$arg}; if (! defined $new_arg) @@ -287,15 +290,27 @@ sub run_test my ($file, $args) = @_; my $outfile = "out.pdf"; - foreach my $arg (@$args) + my $found_in = 0; + my @cmd = ($executable, @$report_mem); + for (@$args) { + my $arg = $_; if ($arg eq '--json-output') { $outfile = "out.json"; - last; } + elsif ($arg eq '') + { + $found_in = 1; + $arg = $file; + } + push(@cmd, $arg); } - my @cmd = ($executable, @$args, @$report_mem, $file, "$workdir/$outfile"); + if (! $found_in) + { + push(@cmd, $file); + } + push(@cmd, "$workdir/$outfile"); # Run once and discard to update caches system("sync"); run_cmd(@cmd);