Fix obsolete comment regarding FSM truncation.
[PostgreSQL.git] / src / test / performance / runtests.pl
blob1d0c53dd2803661ea3b3f0c19717c14cc48b4760
1 #!/usr/bin/perl
3 # Accepts one argument - DBMS name (pgsql, ...) and initializes
4 # global variable $TestDBMS with this name.
7 # Where to run tests
8 $DBNAME = 'perftest';
10 # This describtion for all DBMS supported by test
11 # DBMS_name => [FrontEnd, DestroyDB command, CreateDB command]
13 %DBMS = (
14 'pgsql' => ["psql -q -d $DBNAME", "destroydb $DBNAME", "createdb $DBNAME"]
17 # Tests to run: test' script, test' description, ...
18 # Test' script is in form
20 # script_name[.ntm][ T]
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.)
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',
63 # It seems that nothing below need to be changed
66 $TestDBMS = $ARGV[0];
67 die "Unsupported DBMS $TestDBMS\n" if !exists $DBMS{$TestDBMS};
69 $FrontEnd = $DBMS{$TestDBMS}[0];
70 $DestroyDB = $DBMS{$TestDBMS}[1];
71 $CreateDB = $DBMS{$TestDBMS}[2];
73 print "(Re)create DataBase $DBNAME\n";
75 `$DestroyDB`; # Destroy DB
76 `$CreateDB`; # Create DB
78 $ResFile = "Results.$TestDBMS";
79 $TmpFile = "Tmp.$TestDBMS";
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;
87 for ($i = 0; $i <= $#perftests; $i++)
89 $test = $perftests[$i];
90 ($test, $XACTBLOCK) = split (/ /, $test);
91 $runtest = $test;
92 if ( $test =~ /\.ntm/ )
95 # No timing for this queries
97 close (STDERR); # close $TmpFile
98 open (STDERR, ">/dev/null") or die;
99 $runtest =~ s/\.ntm//;
101 else
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]: ";
112 do "sqls/$runtest";
114 # Restore STDERR to $TmpFile
115 if ( $test =~ /\.ntm/ )
117 close (STDERR);
118 open (STDERR, ">>$TmpFile") or die;
121 select (STDERR); $| = 1;
122 $i++;
125 close (STDERR);
126 open(STDERR, ">&SAVEERR");
128 open (TMPF, "<$TmpFile") or die;
129 open (RESF, ">$ResFile") or die;
131 while (<TMPF>)
133 $str = $_;
134 ($test, $rtime) = split (/:/, $str);
135 ($tmp, $rtime, $rest) = split (/[ ]+/, $rtime);
136 print RESF "$test: $rtime\n";