From 141f281b81d83e1e594d3da256bac70e20b7bcf3 Mon Sep 17 00:00:00 2001 From: "Peter J. Holzer" Date: Thu, 6 May 2021 22:35:38 +0200 Subject: [PATCH] Add Perl/PostgreSQL version --- dcb_perl_psql | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 dcb_perl_psql diff --git a/dcb_perl_psql b/dcb_perl_psql new file mode 100755 index 0000000..927468c --- /dev/null +++ b/dcb_perl_psql @@ -0,0 +1,24 @@ +#!/usr/bin/perl +use v5.30; +use warnings; + +use Time::HiRes qw(clock_gettime CLOCK_MONOTONIC); + +my $t0 = clock_gettime(CLOCK_MONOTONIC); + +use DBI; + +for my $rep (1 .. 2) { + my $t1 = clock_gettime(CLOCK_MONOTONIC); + + my $dbh = DBI->connect("dbi:Pg:", ""); + + my $t2 = clock_gettime(CLOCK_MONOTONIC); + my $result = $dbh->selectall_arrayref("select current_timestamp"); + my $t3 = clock_gettime(CLOCK_MONOTONIC); + $dbh->disconnect(); + my $t4 = clock_gettime(CLOCK_MONOTONIC); + + say $t2 - $t1, " connect $rep"; + say $t4 - $t1, " session $rep"; +}