diff options
author | monty@hundin.mysql.fi <> | 2001-11-28 03:47:15 +0200 |
---|---|---|
committer | monty@hundin.mysql.fi <> | 2001-11-28 03:47:15 +0200 |
commit | 5fedd2dda72f59c1a00525862a093bdaf042d034 (patch) | |
tree | 1591378c44e709fb0ac9df322ad1e001c517ae50 /sql-bench | |
parent | 3c057478c2996b08cebd512ce5f2150853e0145f (diff) | |
download | mariadb-git-5fedd2dda72f59c1a00525862a093bdaf042d034.tar.gz |
Fix for IO_CACHE.
Portability fixes.
Diffstat (limited to 'sql-bench')
-rw-r--r-- | sql-bench/test-transactions.sh | 170 |
1 files changed, 99 insertions, 71 deletions
diff --git a/sql-bench/test-transactions.sh b/sql-bench/test-transactions.sh index 62de009ab33..adb76e6f68d 100644 --- a/sql-bench/test-transactions.sh +++ b/sql-bench/test-transactions.sh @@ -1,5 +1,4 @@ #!@PERL@ -# # Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB # # This library is free software; you can redistribute it and/or @@ -28,7 +27,7 @@ use warnings; $opt_groups=27; # Characters are 'A' -> Z -$opt_loop_count=100000; # Change this to make test harder/easier +$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 ''); @@ -114,86 +113,109 @@ sub test_insert } ### -### Test update perfomance +### Test rollback performance ### -test_update("bench1","update_commit",0); -test_update("bench2","update_autocommit",1); +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 +# -sub test_update { - my ($table, $test_name, $auto_commit)= @_; - my ($loop_time,$end_time,$id); + my ($id,$rev_id,$grp,$region,$end,$loop_time,$end_time,$commit_loop,$count); - $dbh->{AutoCommit}= $auto_commit; + $dbh->{AutoCommit} = 0; $loop_time=new Benchmark; + $end=$opt_loop_count*2; + $count=0; - for ($id=0 ; $id < $opt_loop_count ; $id++) + for ($commit_loop=1, $id=$opt_loop_count ; $id < $end ; + $id++, $commit_loop++) { - do_query($dbh,"update bench1 set updated=1 where idn=$id"); + $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++; } - - $dbh->commit if (!$auto_commit); $end_time=new Benchmark; - print "Time for $test_name ($opt_loop_count): " . + print "Time for insert_rollback ($count:$opt_loop_count): " . timestr(timediff($end_time, $loop_time),"all") . "\n\n"; } -### -### Test delete perfomance -### +## +## Update rollback test +## -test_delete("bench1","delete_commit",0); -test_delete("bench2","delete_autocommit",1); +# +# Test is done by updating 100 rows in a table with lots of rows and +# then doing a rollback on these +# -sub test_delete { - my ($table, $test_name, $auto_commit)= @_; - my ($loop_time,$end_time,$id); + my ($id,$loop_time,$end_time,$commit_loop,$count); - $dbh->{AutoCommit}= $auto_commit; + $dbh->{AutoCommit} = 0; $loop_time=new Benchmark; + $end=$opt_loop_count*2; + $count=0; - for ($id=0 ; $id < $opt_loop_count ; $id++) - { - do_query($dbh,"delete from $table where idn=$id"); + 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++; } - $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"; + print "Time for update_rollback ($count:$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 +## Delete rollback test ## # -# Test is done by inserting 10 rows in a table with lots of rows and +# Test is done by deleting 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); + 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=$opt_loop_count ; $id < $end ; - $id++, $commit_loop++) + for ($commit_loop=1, $id=0 ; $id < $opt_loop_count ; $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)"); + do_query($dbh,"delete from bench1 where idn=$id"); if ($commit_loop >= $opt_medium_loop_count) { $dbh->rollback; @@ -207,56 +229,62 @@ print "Test transactions rollback performance\n" if($opt_debug); $count++; } $end_time=new Benchmark; - print "Time for insert_rollback ($count:$opt_loop_count): " . + print "Time for delete_rollback ($count:$opt_loop_count): " . timestr(timediff($end_time, $loop_time),"all") . "\n\n"; } + ### -### Update rollback test +### Test update perfomance ### -if (0) -{ +test_update("bench1","update_commit",0); +test_update("bench2","update_autocommit",1); - $dbh->{AutoCommit} = 0; +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,$rev_id=$opt_medium_loop_count ; $id < $opt_medium_loop_count; $id++,$rev_id--) + for ($id=0 ; $id < $opt_loop_count ; $id++) { - $grp=$id/$opt_groups; - $region=chr(65+$id%$opt_groups); - do_query($dbh,"update bench1 set region='$region',grp=$grp where idn=$id"); + do_query($dbh,"update bench1 set updated=1 where idn=$id"); } - $dbh->rollback; - + $dbh->commit if (!$auto_commit); $end_time=new Benchmark; - print "Time for update rollback (" . ($opt_medium_loop_count) . "): " . + print "Time for $test_name ($opt_loop_count): " . timestr(timediff($end_time, $loop_time),"all") . "\n\n"; +} -### Delete rollback test - $dbh->{AutoCommit} = 0; +### +### Test delete perfomance +### - $loop_time=new Benchmark; +test_delete("bench1","delete_commit",0); +test_delete("bench2","delete_autocommit",1); - for ($id=0,$rev_id=$opt_medium_loop_count; $id < $opt_medium_loop_count; $id++,$rev_id--) - { - $grp=$id/$opt_groups; - $region=chr(65+$id%$opt_groups); - do_query($dbh,"delete from bench1 where idn=$id"); - } +sub test_delete +{ + my ($table, $test_name, $auto_commit)= @_; + my ($loop_time,$end_time,$id); - $dbh->rollback; + $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 delete rollback (" . ($opt_medium_loop_count) . "): " . - timestr(timediff($end_time, $loop_time),"all") . "\n\n"; - - $dbh->{AutoCommit} = 1; + print "Time for $test_name ($opt_loop_count): " . + timestr(timediff($end_time, $loop_time),"all") . "\n\n"; } - #### #### End of benchmark #### |