Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Add a TAP test for test_json_parser_perf
authorAndrew Dunstan <andrew@dunslane.net>
Tue, 9 Apr 2024 18:23:20 +0000 (14:23 -0400)
committerAndrew Dunstan <andrew@dunslane.net>
Fri, 12 Apr 2024 14:32:30 +0000 (10:32 -0400)
This just makes sure the test can run with a single iteration. A real
performance test would test with many more.

src/test/modules/test_json_parser/meson.build
src/test/modules/test_json_parser/t/004_test_parser_perf.pl [new file with mode: 0644]

index 0e9c3e06982e07b48c812756f05cea3c192db303..b224f3e07e2b863fb91a6390173a1c707068b70a 100644 (file)
@@ -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 (file)
index 0000000..ec322c1
--- /dev/null
@@ -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();