mariadb/sql-bench/test-transactions.sh
unknown 7c999bb032 Query cache.
Remove some warnings


Docs/manual.texi:
  Solaris and gcc
include/ft_global.h:
  Remove warnings
include/myisam.h:
  Query cache
include/myisammrg.h:
  Query cache
include/mysql_com.h:
  Query cache
libmysqld/lib_sql.cc:
  Query cache
myisam/ft_boolean_search.c:
  Remove warnings
myisam/ft_dump.c:
  Remove warnings
myisam/ft_parser.c:
  Remove warnings
myisam/ft_static.c:
  Remove warnings
myisam/ft_update.c:
  Remove warnings
myisam/ftdefs.h:
  Remove warnings
myisam/mi_delete.c:
  Query cache
myisam/mi_locking.c:
  Query cache
myisam/mi_update.c:
  Query cache
myisam/myisamdef.h:
  Optimize for Ia64
myisammrg/myrg_extra.c:
  Query cache
mysys/mf_keycache.c:
  DBUG statements
regex/cclass.h:
  Remove warnings
regex/cname.h:
  Remove warnings
regex/main.c:
  Remove warnings
regex/regcomp.c:
  Remove warnings
regex/regcomp.ih:
  Remove warnings
regex/regerror.c:
  Remove warnings
regex/reginit.c:
  Remove warnings
regex/split.c:
  Remove warnings
sql-bench/test-connect.sh:
  Make tests query-cache safe.
sql-bench/test-transactions.sh:
  Fix for old perl versions
sql/convert.cc:
  Query cache
sql/ha_myisammrg.cc:
  Query cache
sql/ha_myisammrg.h:
  Query cache
sql/handler.cc:
  Query cache
sql/item_create.cc:
  Query cache
sql/item_func.cc:
  Remove warnings
sql/item_func.h:
  Remove warnings
sql/lex.h:
  Query cache
sql/mysql_priv.h:
  Query cache
sql/mysqld.cc:
  Query cache
sql/net_serv.cc:
  Query cache
sql/sql_cache.cc:
  Query cache
sql/sql_class.cc:
  Query cache
sql/sql_class.h:
  Query cache
sql/sql_db.cc:
  Query cache
sql/sql_delete.cc:
  Query cache
sql/sql_insert.cc:
  Query cache
sql/sql_parse.cc:
  Query cache
sql/sql_select.cc:
  Query cache
sql/sql_table.cc:
  Query cache
sql/sql_update.cc:
  Query cache
sql/sql_yacc.yy:
  Query cache
2001-12-02 14:34:01 +02:00

297 lines
7 KiB
Bash

#!@PERL@
# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not, write to the Free
# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
# MA 02111-1307, USA
#
# Test of transactions performance.
#
##################### Standard benchmark inits ##############################
use DBI;
use Benchmark;
#use warnings;
$opt_groups=27; # Characters are 'A' -> Z
$opt_loop_count=10000; # Change this to make test harder/easier
$opt_medium_loop_count=100; # Change this to make test harder/easier
chomp($pwd = `pwd`); $pwd = "." if ($pwd eq '');
require "$pwd/bench-init.pl" || die "Can't read Configuration file: $!\n";
# Avoid warnings for variables in bench-init.pl
# (Only works with perl 5.6)
#our ($opt_small_test, $opt_small_tables, $opt_debug, $opt_force);
if ($opt_small_test || $opt_small_tables)
{
$opt_loop_count/=100;
$opt_medium_loop_count/=10;
}
if (!$server->{transactions} && !$opt_force)
{
print "Test skipped because the database doesn't support transactions\n";
exit(0);
}
####
#### Connect and start timeing
####
$start_time=new Benchmark;
$dbh = $server->connect();
###
### Create Table
###
print "Creating tables\n";
$dbh->do("drop table bench1");
$dbh->do("drop table bench2");
do_many($dbh,$server->create("bench1",
["idn int NOT NULL",
"rev_idn int NOT NULL",
"region char(1) NOT NULL",
"grp int NOT NULL",
"updated tinyint NOT NULL"],
["primary key (idn)",
"unique (region,grp)"]));
do_many($dbh,$server->create("bench2",
["idn int NOT NULL",
"rev_idn int NOT NULL",
"region char(1) NOT NULL",
"grp int NOT NULL",
"updated tinyint NOT NULL"],
["primary key (idn)",
"unique (region,grp)"]));
$dbh->{AutoCommit} = 0;
###
### Test insert perfomance
###
test_insert("bench1","insert_commit",0);
test_insert("bench2","insert_autocommit",1);
sub test_insert
{
my ($table, $test_name, $auto_commit)= @_;
my ($loop_time,$end_time,$id,$rev_id,$grp,$region);
$dbh->{AutoCommit}= $auto_commit;
$loop_time=new Benchmark;
for ($id=0,$rev_id=$opt_loop_count-1 ; $id < $opt_loop_count ;
$id++,$rev_id--)
{
$grp=$id/$opt_groups;
$region=chr(65+$id%$opt_groups);
do_query($dbh,"insert into $table values ($id,$rev_id,'$region',$grp,0)");
}
$dbh->commit if (!$auto_commit);
$end_time=new Benchmark;
print "Time for $test_name ($opt_loop_count): " .
timestr(timediff($end_time, $loop_time),"all") . "\n\n";
}
###
### Test rollback performance
###
print "Test transactions rollback performance\n" if($opt_debug);
##
## Insert rollback test
##
#
# Test is done by inserting 100 rows in a table with lots of rows and
# then doing a rollback on these
#
{
my ($id,$rev_id,$grp,$region,$end,$loop_time,$end_time,$commit_loop,$count);
$dbh->{AutoCommit} = 0;
$loop_time=new Benchmark;
$end=$opt_loop_count*2;
$count=0;
for ($commit_loop=1, $id=$opt_loop_count ; $id < $end ;
$id++, $commit_loop++)
{
$rev_id=$end-$id;
$grp=$id/$opt_groups;
$region=chr(65+$id%$opt_groups);
do_query($dbh,"insert into bench1 values ($id,$rev_id,'$region',$grp,0)");
if ($commit_loop >= $opt_medium_loop_count)
{
$dbh->rollback;
$commit_loop=0;
$count++;
}
}
if ($commit_loop > 1)
{
$dbh->rollback;
$count++;
}
$end_time=new Benchmark;
print "Time for insert_rollback ($count:$opt_loop_count): " .
timestr(timediff($end_time, $loop_time),"all") . "\n\n";
}
##
## Update rollback test
##
#
# Test is done by updating 100 rows in a table with lots of rows and
# then doing a rollback on these
#
{
my ($id,$loop_time,$end_time,$commit_loop,$count);
$dbh->{AutoCommit} = 0;
$loop_time=new Benchmark;
$end=$opt_loop_count*2;
$count=0;
for ($commit_loop=1, $id=0 ; $id < $opt_loop_count ; $id++, $commit_loop++)
{
do_query($dbh,"update bench1 set updated=2 where idn=$id");
if ($commit_loop >= $opt_medium_loop_count)
{
$dbh->rollback;
$commit_loop=0;
$count++;
}
}
if ($commit_loop > 1)
{
$dbh->rollback;
$count++;
}
$end_time=new Benchmark;
print "Time for update_rollback ($count:$opt_loop_count): " .
timestr(timediff($end_time, $loop_time),"all") . "\n\n";
}
##
## Delete rollback test
##
#
# Test is done by deleting 100 rows in a table with lots of rows and
# then doing a rollback on these
#
{
my ($id,$loop_time,$end_time,$commit_loop,$count);
$dbh->{AutoCommit} = 0;
$loop_time=new Benchmark;
$end=$opt_loop_count*2;
$count=0;
for ($commit_loop=1, $id=0 ; $id < $opt_loop_count ; $id++, $commit_loop++)
{
do_query($dbh,"delete from bench1 where idn=$id");
if ($commit_loop >= $opt_medium_loop_count)
{
$dbh->rollback;
$commit_loop=0;
$count++;
}
}
if ($commit_loop > 1)
{
$dbh->rollback;
$count++;
}
$end_time=new Benchmark;
print "Time for delete_rollback ($count:$opt_loop_count): " .
timestr(timediff($end_time, $loop_time),"all") . "\n\n";
}
###
### Test update perfomance
###
test_update("bench1","update_commit",0);
test_update("bench2","update_autocommit",1);
sub test_update
{
my ($table, $test_name, $auto_commit)= @_;
my ($loop_time,$end_time,$id);
$dbh->{AutoCommit}= $auto_commit;
$loop_time=new Benchmark;
for ($id=0 ; $id < $opt_loop_count ; $id++)
{
do_query($dbh,"update bench1 set updated=1 where idn=$id");
}
$dbh->commit if (!$auto_commit);
$end_time=new Benchmark;
print "Time for $test_name ($opt_loop_count): " .
timestr(timediff($end_time, $loop_time),"all") . "\n\n";
}
###
### Test delete perfomance
###
test_delete("bench1","delete_commit",0);
test_delete("bench2","delete_autocommit",1);
sub test_delete
{
my ($table, $test_name, $auto_commit)= @_;
my ($loop_time,$end_time,$id);
$dbh->{AutoCommit}= $auto_commit;
$loop_time=new Benchmark;
for ($id=0 ; $id < $opt_loop_count ; $id++)
{
do_query($dbh,"delete from $table where idn=$id");
}
$dbh->commit if (!$auto_commit);
$end_time=new Benchmark;
print "Time for $test_name ($opt_loop_count): " .
timestr(timediff($end_time, $loop_time),"all") . "\n\n";
}
####
#### End of benchmark
####
$sth = $dbh->do("drop table bench1" . $server->{'drop_attr'}) or die $DBI::errstr;
$sth = $dbh->do("drop table bench2" . $server->{'drop_attr'}) or die $DBI::errstr;
$dbh->disconnect; # close connection
end_benchmark($start_time);