Skip to content

Commit cf76759

Browse files
committed
Start with performance suite.
1 parent 561b35e commit cf76759

File tree

2 files changed

+144
-0
lines changed

2 files changed

+144
-0
lines changed

src/test/performance/runtests.pl

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
#!/usr/local/bin/perl
2+
#
3+
# Accepts one argument - DBMS name (pgsql, ...) and initializes
4+
# global variable $TestDBMS with this name.
5+
#
6+
7+
# Where to run tests
8+
$DBNAME = 'perftest';
9+
10+
# This describtion for all DBMS supported by test
11+
# DBMS_name => [FrontEnd, DestroyDB command, CreateDB command]
12+
13+
%DBMS = (
14+
'pgsql' => ["psql -q -d $DBNAME", "destroydb $DBNAME", "createdb $DBNAME"]
15+
);
16+
17+
# Tests to run: test' script, test' description, ...
18+
# Test' script is in form
19+
#
20+
# script_name[.ntm][ T]
21+
#
22+
# script_name is name of file in ./sqls
23+
# .ntm means that script will be used for some initialization
24+
# and should not be timed: runtests.pl opens /dev/null as STDERR
25+
# in this case and restore STDERR to result file after script done.
26+
# Script shouldn't notice either he is running for test or for
27+
# initialization purposes.
28+
# T means that all queries in this test (initialization ?) are to be
29+
# executed in SINGLE transaction. In this case global variable $XACTBLOCK
30+
# is not empty string. Otherwise, each query in test is to be executed
31+
# in own transaction ($XACTBLOCK is empty string). In accordance with
32+
# $XACTBLOCK, script is to do DBMS specific preparation before execution
33+
# of queries. (Look at example in sqls/inssimple for MySQL - it gives
34+
# an idea of what can be done for features unsupported by an DBMS.)
35+
#
36+
@perftests = (
37+
# It speed up things
38+
'connection.ntm', 'DB connection startup (no timing)',
39+
# Just connection startup time (echo "" | psql ... - for PgSQL)
40+
'connection', 'DB connection startup',
41+
'crtsimple.ntm', 'Create SIMPLE table (no timing)',
42+
# 8192 inserts in single xaction
43+
'inssimple T', '8192 INSERTs INTO SIMPLE (1 xact)',
44+
'drpsimple.ntm', 'Drop SIMPLE table (no timing)',
45+
'crtsimple.ntm', 'Create SIMPLE table (no timing)',
46+
# 8192 inserts in 8192 xactions
47+
'inssimple', '8192 INSERTs INTO SIMPLE (8192 xacts)',
48+
'vacuum.ntm', 'Vacuum (no timing)',
49+
# Fast (after table filled with data) index creation test
50+
'crtsimpleidx', 'Create INDEX on SIMPLE',
51+
'drpsimple.ntm', 'Drop SIMPLE table (no timing)',
52+
'crtsimple.ntm', 'Create SIMPLE table (no timing)',
53+
'crtsimpleidx.ntm', 'Create INDEX on SIMPLE (no timing)',
54+
# 8192 inserts in single xaction into table with index
55+
'inssimple T', '8192 INSERTs INTO SIMPLE with INDEX (1 xact)',
56+
# 8192 SELECT * FROM simple WHERE justint = <random_key> in single xaction
57+
'slcsimple T', '8192 random INDEX scans on SIMPLE (1 xact)',
58+
# SELECT * FROM simple ORDER BY justint
59+
'orbsimple', 'ORDER BY SIMPLE',
60+
);
61+
62+
#
63+
# It seems that nothing below need to be changed
64+
#
65+
66+
$TestDBMS = $ARGV[0];
67+
die "Unsupported DBMS $TestDBMS\n" if !exists $DBMS{$TestDBMS};
68+
69+
$FrontEnd = $DBMS{$TestDBMS}[0];
70+
$DestroyDB = $DBMS{$TestDBMS}[1];
71+
$CreateDB = $DBMS{$TestDBMS}[2];
72+
73+
print "(Re)create DataBase $DBNAME\n";
74+
75+
`$DestroyDB`; # Destroy DB
76+
`$CreateDB`; # Create DB
77+
78+
$ResFile = "Results.$TestDBMS";
79+
$TmpFile = "Tmp.$TestDBMS";
80+
81+
open (SAVEOUT, ">&STDOUT");
82+
open (STDOUT, ">/dev/null") or die;
83+
open (SAVEERR, ">&STDERR");
84+
open (STDERR, ">$TmpFile") or die;
85+
select (STDERR); $| = 1;
86+
87+
for ($i = 0; $i <= $#perftests; $i++)
88+
{
89+
$test = $perftests[$i];
90+
($test, $XACTBLOCK) = split (/ /, $test);
91+
$runtest = $test;
92+
if ( $test =~ /\.ntm/ )
93+
{
94+
#
95+
# No timing for this queries
96+
#
97+
close (STDERR); # close $TmpFile
98+
open (STDERR, ">/dev/null") or die;
99+
$runtest =~ s/\.ntm//;
100+
}
101+
else
102+
{
103+
close (STDOUT);
104+
open(STDOUT, ">&SAVEOUT");
105+
print STDOUT "\nRunning: $perftests[$i+1] ...";
106+
close (STDOUT);
107+
open (STDOUT, ">/dev/null") or die;
108+
select (STDERR); $| = 1;
109+
printf "$perftests[$i+1]: ";
110+
}
111+
112+
do "sqls/$runtest";
113+
114+
# Restore STDERR to $TmpFile
115+
if ( $test =~ /\.ntm/ )
116+
{
117+
close (STDERR);
118+
open (STDERR, ">>$TmpFile") or die;
119+
}
120+
121+
select (STDERR); $| = 1;
122+
$i++;
123+
}
124+
125+
close (STDERR);
126+
open(STDERR, ">&SAVEERR");
127+
128+
open (TMPF, "<$TmpFile") or die;
129+
open (RESF, ">$ResFile") or die;
130+
131+
while (<TMPF>)
132+
{
133+
$str = $_;
134+
($test, $rtime) = split (/:/, $str);
135+
($tmp, $rtime, $rest) = split (/[ ]+/, $rtime);
136+
print RESF "$test: $rtime\n";
137+
}
138+

src/test/performance/start-pgsql.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
3+
# Please choose amount of sort memory (-S XXX) as appropriate
4+
# for your system: more is better, but swapping breaks performance!
5+
6+
exec postmaster -B 256 '-o -S 2048' -S

0 commit comments

Comments
 (0)