aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dunstan <andrew@dunslane.net>2024-04-09 14:23:20 -0400
committerAndrew Dunstan <andrew@dunslane.net>2024-04-12 10:32:30 -0400
commitdaf554dbeabf0957a25c9e37488d42c047c0ce23 (patch)
treeb3bb77e9f4433c1f367c298f36188a3cd774e0fa
parent661ab4e185784db79c194b5758555b1db3f30483 (diff)
downloadpostgresql-daf554dbeabf0957a25c9e37488d42c047c0ce23.tar.gz
postgresql-daf554dbeabf0957a25c9e37488d42c047c0ce23.zip
Add a TAP test for test_json_parser_perf
This just makes sure the test can run with a single iteration. A real performance test would test with many more.
-rw-r--r--src/test/modules/test_json_parser/meson.build3
-rw-r--r--src/test/modules/test_json_parser/t/004_test_parser_perf.pl35
2 files changed, 37 insertions, 1 deletions
diff --git a/src/test/modules/test_json_parser/meson.build b/src/test/modules/test_json_parser/meson.build
index 0e9c3e06982..b224f3e07e2 100644
--- a/src/test/modules/test_json_parser/meson.build
+++ b/src/test/modules/test_json_parser/meson.build
@@ -46,7 +46,8 @@ tests += {
'tests': [
't/001_test_json_parser_incremental.pl',
't/002_inline.pl',
- 't/003_test_semantic.pl'
+ 't/003_test_semantic.pl',
+ 't/004_test_parser_perf.pl'
],
},
}
diff --git a/src/test/modules/test_json_parser/t/004_test_parser_perf.pl b/src/test/modules/test_json_parser/t/004_test_parser_perf.pl
new file mode 100644
index 00000000000..ec322c13912
--- /dev/null
+++ b/src/test/modules/test_json_parser/t/004_test_parser_perf.pl
@@ -0,0 +1,35 @@
+
+use strict;
+use warnings;
+
+use PostgreSQL::Test::Utils;
+use Test::More;
+use FindBin;
+
+use File::Temp qw(tempfile);
+
+my $test_file = "$FindBin::RealBin/../tiny.json";
+
+my $exe = "test_json_parser_perf";
+
+my $contents = slurp_file($test_file);
+
+my ($fh, $fname) = tempfile(UNLINK => 1);
+
+# repeat the input json file 50 times in an array
+
+print $fh, '[', $contents , ",$contents" x 49 , ']';
+
+close($fh);
+
+# but only do one iteration
+
+my ($result) = run_log([ $exe, "1", $fname ] );
+
+ok($result == 0, "perf test runs with RD parser");
+
+$result = run_log([ $exe, "-i" , "1", $fname ]);
+
+ok($result == 0, "perf test runs with table driven parser");
+
+done_testing();