aboutsummaryrefslogtreecommitdiffstats
path: root/performance_check
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-05-21 16:04:33 +0200
committerJay Berkenbilt <ejb@ql.org>2022-05-21 16:04:33 +0200
commit70ccd807c45f477d6caf73b9390ba3acda53d1db (patch)
treec9c08e65a3a327866394ae22c25bd8c6524c2e03 /performance_check
parent341cd7b5d9a2edf1f2bc0d3bffee4734bbc185d4 (diff)
downloadqpdf-70ccd807c45f477d6caf73b9390ba3acda53d1db.tar.zst
Add json to performance tests
Diffstat (limited to 'performance_check')
-rwxr-xr-xperformance_check76
1 files changed, 61 insertions, 15 deletions
diff --git a/performance_check b/performance_check
index cb93b643..843ae79e 100755
--- a/performance_check
+++ b/performance_check
@@ -18,6 +18,8 @@ my @tests = (
['shared resource check', ['--split-pages', '--remove-unreferenced-resources=auto']],
['linearize', ['--linearize']],
['encrypt', ['--encrypt', 'u', 'o', '256', '--']],
+ ['json-output', ['--json-output']],
+ ['json-input', ['--json-input']],
);
# If arg is not found in help output, look here. If not here, skip test.
@@ -34,12 +36,14 @@ my $test_dir = undef;
my $test_file = undef;
my $workdir = undef;
my $maxtime = undef;
+my $iterations = undef;
my $default_executable = 'build/qpdf/qpdf';
my $default_test_dir = '../performance-test-files';
my $default_test_file = undef;
my $default_workdir = 'build/perf';
my $default_maxtime = 20;
+my $default_iterations = 20;
sub usage
{
@@ -50,6 +54,7 @@ Usage: $whoami [ args ]
--executable qpdf use the specified qpdf (default: $default_executable)
--workdir where to write output pdfs (default: $default_workdir)
--maxtime maximum time for a test; 0 means unlimited (default: $default_maxtime)
+ --iterations number of iterations (default: $default_iterations)
";
}
@@ -83,6 +88,11 @@ while (@ARGV)
usage() unless @ARGV;
$maxtime = shift(@ARGV);
}
+ elsif ('--iterations' eq $arg)
+ {
+ usage() unless @ARGV;
+ $iterations = shift(@ARGV);
+ }
else
{
usage();
@@ -105,21 +115,40 @@ if (! defined $maxtime)
{
$maxtime = $default_maxtime;
}
-
-my @test_files = ();
-if (defined $test_file)
+if (! defined $iterations)
{
- push(@test_files, $test_file);
+ $iterations = $default_iterations;
}
-else
-{
- opendir(D, $test_dir) or
- die "$whoami: can't open directory $test_dir: $!\n";
- my @entries = readdir(D);
- closedir(D);
- for (sort @entries)
+
+my @test_files = ();
+my @json_test_files = ();
+{ # private scope
+ my @tmp = ();
+ if (defined $test_file)
+ {
+ push(@tmp, $test_file);
+ }
+ else
+ {
+ opendir(D, $test_dir) or
+ die "$whoami: can't open directory $test_dir: $!\n";
+ my @entries = readdir(D);
+ closedir(D);
+ for (sort @entries)
+ {
+ push(@tmp, "$test_dir/$_") unless (('.' eq $_) || ('..' eq $_));
+ }
+ }
+ foreach my $i (@tmp)
{
- push(@test_files, "$test_dir/$_") unless (('.' eq $_) || ('..' eq $_));
+ if ($i =~ m/.json$/)
+ {
+ push(@json_test_files, $i);
+ }
+ else
+ {
+ push(@test_files, $i);
+ }
}
}
@@ -173,7 +202,16 @@ sub run_tests
print " skipping (unknown arguments)\n";
next;
}
- foreach my $file (@test_files)
+ my $test_files = \@test_files;
+ foreach my $arg (@$args)
+ {
+ if ($arg eq '--json-input')
+ {
+ $test_files = \@json_test_files;
+ last;
+ }
+ }
+ foreach my $file (@$test_files)
{
my $time = run_test($file, $args);
if (defined $time)
@@ -192,8 +230,16 @@ sub run_test
{
my ($file, $args) = @_;
- my $iterations = 20;
- my @cmd = ($executable, @$args, $file, "$workdir/out.pdf");
+ my $outfile = "out.pdf";
+ foreach my $arg (@$args)
+ {
+ if ($arg eq '--json-output')
+ {
+ $outfile = "out.json";
+ last;
+ }
+ }
+ my @cmd = ($executable, @$args, $file, "$workdir/$outfile");
# Run once and discard to update caches
system("sync");
system(@cmd);