$DBNAME = 'perftest';
%DBMS =
('pgsql' =>
[ "psql -q -d $DBNAME", "destroydb $DBNAME", "createdb $DBNAME" ]);
@perftests = (
'connection.ntm', 'DB connection startup (no timing)',
'connection', 'DB connection startup',
'crtsimple.ntm', 'Create SIMPLE table (no timing)',
'inssimple T', '8192 INSERTs INTO SIMPLE (1 xact)',
'drpsimple.ntm', 'Drop SIMPLE table (no timing)',
'crtsimple.ntm', 'Create SIMPLE table (no timing)',
'inssimple', '8192 INSERTs INTO SIMPLE (8192 xacts)',
'vacuum.ntm', 'Vacuum (no timing)',
'crtsimpleidx', 'Create INDEX on SIMPLE',
'drpsimple.ntm', 'Drop SIMPLE table (no timing)',
'crtsimple.ntm', 'Create SIMPLE table (no timing)',
'crtsimpleidx.ntm', 'Create INDEX on SIMPLE (no timing)',
'inssimple T', '8192 INSERTs INTO SIMPLE with INDEX (1 xact)',
'slcsimple T', '8192 random INDEX scans on SIMPLE (1 xact)',
'orbsimple', 'ORDER BY SIMPLE',);
$TestDBMS = $ARGV[0];
die "Unsupported DBMS $TestDBMS\n" if !exists $DBMS{$TestDBMS};
$FrontEnd = $DBMS{$TestDBMS}[0];
$DestroyDB = $DBMS{$TestDBMS}[1];
$CreateDB = $DBMS{$TestDBMS}[2];
print "(Re)create DataBase $DBNAME\n";
`$DestroyDB`;
`$CreateDB`;
$ResFile = "Results.$TestDBMS";
$TmpFile = "Tmp.$TestDBMS";
open(SAVEOUT, ">&STDOUT");
open(STDOUT, ">/dev/null") or die;
open(SAVEERR, ">&STDERR");
open(STDERR, ">$TmpFile") or die;
select(STDERR);
$| = 1;
for ($i = 0; $i <= $#perftests; $i++)
{
$test = $perftests[$i];
($test, $XACTBLOCK) = split(/ /, $test);
$runtest = $test;
if ($test =~ /\.ntm/)
{
close(STDERR);
open(STDERR, ">/dev/null") or die;
$runtest =~ s/\.ntm//;
}
else
{
close(STDOUT);
open(STDOUT, ">&SAVEOUT");
print STDOUT "\nRunning: $perftests[$i+1] ...";
close(STDOUT);
open(STDOUT, ">/dev/null") or die;
select(STDERR);
$| = 1;
printf "$perftests[$i+1]: ";
}
do "sqls/$runtest";
if ($test =~ /\.ntm/)
{
close(STDERR);
open(STDERR, ">>$TmpFile") or die;
}
select(STDERR);
$| = 1;
$i++;
}
close(STDERR);
open(STDERR, ">&SAVEERR");
open(TMPF, "<$TmpFile") or die;
open(RESF, ">$ResFile") or die;
while (<TMPF>)
{
$str = $_;
($test, $rtime) = split(/:/, $str);
($tmp, $rtime, $rest) = split(/[ ]+/, $rtime);
print RESF "$test: $rtime\n";
}