2
# Copyright (C) 2000-2001, 2003 MySQL AB
4
# This library is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU Library General Public
6
# License as published by the Free Software Foundation; version 2
9
# This library is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
# Library General Public License for more details.
14
# You should have received a copy of the GNU Library General Public
15
# License along with this library; if not, write to the Free
16
# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
19
# Test of extreme tables.
22
##################### Standard benchmark inits ##############################
28
$opt_loop_count=1000; # Change this to make test harder/easier
29
$opt_field_count=1000;
31
$pwd = cwd(); $pwd = "." if ($pwd eq '');
32
require "$pwd/bench-init.pl" || die "Can't read Configuration file: $!\n";
34
$opt_field_count=min($opt_field_count,$limits->{'max_columns'},
35
($limits->{'query_size'}-30)/14);
37
$opt_loop_count*=10 if ($opt_field_count<100); # mSQL has so few fields...
46
print "Testing of some unusual tables\n";
47
print "All tests are done $opt_loop_count times with $opt_field_count fields\n\n";
51
#### Testing many fields
54
$dbh = $server->connect();
55
print "Testing table with $opt_field_count fields\n";
57
$sth = $dbh->do("drop table bench1" . $server->{'drop_attr'});
62
push(@fields,"$fields int");
63
$values= "1," x ($opt_field_count-1) . "1";
64
for ($i=2 ; $i <= $opt_field_count ; $i++)
66
push(@fields,"i${i} int");
70
$start_time=new Benchmark;
72
do_many($dbh,$server->create("bench1",\@fields,\@index));
73
$sth = $dbh->do("insert into bench1 values ($values)") or die $DBI::errstr;
75
if ($opt_fast && defined($server->{vacuum}))
77
$server->vacuum(0,\$dbh);
80
test_query("Testing select * from table with 1 record",
81
"Time to select_many_fields",
82
"select * from bench1",
83
$dbh,$opt_loop_count);
86
if ($limits->{'working_all_fields'})
88
test_query("Testing select all_fields from table with 1 record",
89
"Time to select_many_fields",
90
"select $fields from bench1",
91
$dbh,$opt_loop_count);
94
test_query("Testing insert VALUES()",
95
"Time to insert_many_fields",
96
"insert into bench1 values($values)",
97
$dbh,$opt_loop_count);
99
if ($opt_fast && defined($server->{vacuum}))
101
$server->vacuum(0,\$dbh);
104
test_command("Testing insert (all_fields) VALUES()",
105
"Time to insert_many_fields",
106
"insert into bench1 ($fields) values($values)",
107
$dbh,$opt_loop_count);
109
$sth = $dbh->do("drop table bench1" . $server->{'drop_attr'}) or die $DBI::errstr;
111
if ($opt_fast && defined($server->{vacuum}))
113
$server->vacuum(0,\$dbh);
116
################################ END ###################################
118
#### End of the test...Finally print time used to execute the
123
end_benchmark($start_time);
126
############################ HELP FUNCTIONS ##############################
130
my($test_text,$result_text,$query,$dbh,$count)=@_;
131
my($i,$loop_time,$end_time, $using_transactions);
133
print $test_text . "\n";
134
$loop_time=new Benchmark;
136
$using_transactions=0;
137
if ($opt_fast && server->{transactions} && $query=~ /^insert /i)
139
$using_transactions=1;
140
$dbh->{AutoCommit} = 0;
141
print "Transactions enabled\n" if ($opt_debug);
143
for ($i=0 ; $i < $count ; $i++)
145
defined(fetch_all_rows($dbh,$query)) or die $DBI::errstr;
147
if ($using_transactions)
150
$dbh->{AutoCommit} = 1;
153
$end_time=new Benchmark;
154
print $result_text . "($count): " .
155
timestr(timediff($end_time, $loop_time),"all") . "\n\n";
161
my($test_text,$result_text,$query,$dbh,$count)=@_;
162
my($i,$loop_time,$end_time);
164
print $test_text . "\n";
165
$loop_time=new Benchmark;
166
for ($i=0 ; $i < $count ; $i++)
168
$dbh->do($query) or die $DBI::errstr;
170
$end_time=new Benchmark;
171
print $result_text . "($count): " .
172
timestr(timediff($end_time, $loop_time),"all") . "\n\n";