mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 19:08:59 +00:00
Add json to performance tests
This commit is contained in:
parent
341cd7b5d9
commit
70ccd807c4
3
TODO
3
TODO
@ -84,9 +84,6 @@ General things to remember:
|
|||||||
non-compatible json 2 changes. Scrutinize all the output to decide
|
non-compatible json 2 changes. Scrutinize all the output to decide
|
||||||
what should change.
|
what should change.
|
||||||
|
|
||||||
* When we get to full serialization, add json serialization
|
|
||||||
performance test.
|
|
||||||
|
|
||||||
* Document that keys other than "qpdf-v2" are ignored so people can
|
* Document that keys other than "qpdf-v2" are ignored so people can
|
||||||
stash their own stuff.
|
stash their own stuff.
|
||||||
|
|
||||||
|
@ -18,6 +18,8 @@ my @tests = (
|
|||||||
['shared resource check', ['--split-pages', '--remove-unreferenced-resources=auto']],
|
['shared resource check', ['--split-pages', '--remove-unreferenced-resources=auto']],
|
||||||
['linearize', ['--linearize']],
|
['linearize', ['--linearize']],
|
||||||
['encrypt', ['--encrypt', 'u', 'o', '256', '--']],
|
['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.
|
# 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 $test_file = undef;
|
||||||
my $workdir = undef;
|
my $workdir = undef;
|
||||||
my $maxtime = undef;
|
my $maxtime = undef;
|
||||||
|
my $iterations = undef;
|
||||||
|
|
||||||
my $default_executable = 'build/qpdf/qpdf';
|
my $default_executable = 'build/qpdf/qpdf';
|
||||||
my $default_test_dir = '../performance-test-files';
|
my $default_test_dir = '../performance-test-files';
|
||||||
my $default_test_file = undef;
|
my $default_test_file = undef;
|
||||||
my $default_workdir = 'build/perf';
|
my $default_workdir = 'build/perf';
|
||||||
my $default_maxtime = 20;
|
my $default_maxtime = 20;
|
||||||
|
my $default_iterations = 20;
|
||||||
|
|
||||||
sub usage
|
sub usage
|
||||||
{
|
{
|
||||||
@ -50,6 +54,7 @@ Usage: $whoami [ args ]
|
|||||||
--executable qpdf use the specified qpdf (default: $default_executable)
|
--executable qpdf use the specified qpdf (default: $default_executable)
|
||||||
--workdir where to write output pdfs (default: $default_workdir)
|
--workdir where to write output pdfs (default: $default_workdir)
|
||||||
--maxtime maximum time for a test; 0 means unlimited (default: $default_maxtime)
|
--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;
|
usage() unless @ARGV;
|
||||||
$maxtime = shift(@ARGV);
|
$maxtime = shift(@ARGV);
|
||||||
}
|
}
|
||||||
|
elsif ('--iterations' eq $arg)
|
||||||
|
{
|
||||||
|
usage() unless @ARGV;
|
||||||
|
$iterations = shift(@ARGV);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
usage();
|
usage();
|
||||||
@ -105,11 +115,18 @@ if (! defined $maxtime)
|
|||||||
{
|
{
|
||||||
$maxtime = $default_maxtime;
|
$maxtime = $default_maxtime;
|
||||||
}
|
}
|
||||||
|
if (! defined $iterations)
|
||||||
|
{
|
||||||
|
$iterations = $default_iterations;
|
||||||
|
}
|
||||||
|
|
||||||
my @test_files = ();
|
my @test_files = ();
|
||||||
|
my @json_test_files = ();
|
||||||
|
{ # private scope
|
||||||
|
my @tmp = ();
|
||||||
if (defined $test_file)
|
if (defined $test_file)
|
||||||
{
|
{
|
||||||
push(@test_files, $test_file);
|
push(@tmp, $test_file);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -119,7 +136,19 @@ else
|
|||||||
closedir(D);
|
closedir(D);
|
||||||
for (sort @entries)
|
for (sort @entries)
|
||||||
{
|
{
|
||||||
push(@test_files, "$test_dir/$_") unless (('.' eq $_) || ('..' eq $_));
|
push(@tmp, "$test_dir/$_") unless (('.' eq $_) || ('..' eq $_));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach my $i (@tmp)
|
||||||
|
{
|
||||||
|
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";
|
print " skipping (unknown arguments)\n";
|
||||||
next;
|
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);
|
my $time = run_test($file, $args);
|
||||||
if (defined $time)
|
if (defined $time)
|
||||||
@ -192,8 +230,16 @@ sub run_test
|
|||||||
{
|
{
|
||||||
my ($file, $args) = @_;
|
my ($file, $args) = @_;
|
||||||
|
|
||||||
my $iterations = 20;
|
my $outfile = "out.pdf";
|
||||||
my @cmd = ($executable, @$args, $file, "$workdir/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
|
# Run once and discard to update caches
|
||||||
system("sync");
|
system("sync");
|
||||||
system(@cmd);
|
system(@cmd);
|
||||||
|
Loading…
Reference in New Issue
Block a user