mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-01 06:27:03 +03:00
Add test file sort4.test, containing brute force tests for the multi-theaded sorter.
FossilOrigin-Name: 9cc364c42cc64ab7b55b5c55e303fb63a456cf00
This commit is contained in:
13
manifest
13
manifest
@ -1,5 +1,5 @@
|
||||
C Fix\sa\srace\scondition\sin\sthe\ssorter\scode.
|
||||
D 2014-05-05T15:58:40.542
|
||||
C Add\stest\sfile\ssort4.test,\scontaining\sbrute\sforce\stests\sfor\sthe\smulti-theaded\ssorter.
|
||||
D 2014-05-05T20:03:50.967
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in ad0921c4b2780d01868cf69b419a4f102308d125
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@ -741,7 +741,7 @@ F test/pagesize.test 1dd51367e752e742f58e861e65ed7390603827a0
|
||||
F test/pcache.test b09104b03160aca0d968d99e8cd2c5b1921a993d
|
||||
F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025
|
||||
F test/percentile.test b98fc868d71eb5619d42a1702e9ab91718cbed54
|
||||
F test/permutations.test 46a18489379943fcbd2ef07faa3858a88adb30cb
|
||||
F test/permutations.test 465bc22a873ced74a6d1dedc0dde5da424be6e6a
|
||||
F test/pragma.test adb21a90875bc54a880fa939c4d7c46598905aa0
|
||||
F test/pragma2.test aea7b3d82c76034a2df2b38a13745172ddc0bc13
|
||||
F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552
|
||||
@ -824,6 +824,7 @@ F test/softheap1.test 40562fe6cac6d9827b7b42b86d45aedf12c15e24
|
||||
F test/sort.test 688468cef8c9a66fcc1d54235de8e4deac745690
|
||||
F test/sort2.test c5e25eb674689e291d06b5209fe8d337ae0ec010
|
||||
F test/sort3.test 6178ade30810ac9166fcdf14b7065e49c0f534e2
|
||||
F test/sort4.test a29761a7d05f194e516e91a03d38f8194ac9849d
|
||||
F test/sortfault.test 1a12b6e27d475f50658a8164aaa34f0080a86b36
|
||||
F test/speed1.test f2974a91d79f58507ada01864c0e323093065452
|
||||
F test/speed1p.explain d841e650a04728b39e6740296b852dccdca9b2cb
|
||||
@ -1170,7 +1171,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
|
||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
|
||||
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
|
||||
P bde28b702dabd02269e333535cc41481351c5efc
|
||||
R e53afa0ba1bd427219aede77058d3d04
|
||||
P 2d2edfe58db101d42a96772b856e6e55b401aab6
|
||||
R a3f7784643670968322db5c49315411c
|
||||
U dan
|
||||
Z ba1cae0a2780ce3568cf6b58bd76a820
|
||||
Z cca87b3c456f151b38b423a6310da351
|
||||
|
@ -1 +1 @@
|
||||
2d2edfe58db101d42a96772b856e6e55b401aab6
|
||||
9cc364c42cc64ab7b55b5c55e303fb63a456cf00
|
@ -112,7 +112,7 @@ set allquicktests [test_set $alltests -exclude {
|
||||
incrvacuum_ioerr.test autovacuum_crash.test btree8.test shared_err.test
|
||||
vtab_err.test walslow.test walcrash.test walcrash3.test
|
||||
walthread.test rtree3.test indexfault.test securedel2.test
|
||||
sort3.test
|
||||
sort3.test sort4.test
|
||||
}]
|
||||
if {[info exists ::env(QUICKTEST_INCLUDE)]} {
|
||||
set allquicktests [concat $allquicktests $::env(QUICKTEST_INCLUDE)]
|
||||
|
145
test/sort4.test
Normal file
145
test/sort4.test
Normal file
@ -0,0 +1,145 @@
|
||||
# 2014 May 6.
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
# This file implements regression tests for SQLite library.
|
||||
#
|
||||
# The tests in this file are brute force tests of the multi-threaded
|
||||
# sorter.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
set testprefix sort4
|
||||
|
||||
catch { db close }
|
||||
sqlite3_shutdown
|
||||
sqlite3_config_worker_threads 3
|
||||
sqlite3_initialize
|
||||
reset_db
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Set up a table "t1" containing $nRow rows. Each row contains also
|
||||
# contains blob fields that total to at least $nPayload bytes of
|
||||
# content.
|
||||
#
|
||||
proc populate_table {nRow nPayload} {
|
||||
set nCol 0
|
||||
|
||||
set n 0
|
||||
for {set nCol 0} {$n < $nPayload} {incr nCol} {
|
||||
incr n [expr (4 << $nCol)]
|
||||
}
|
||||
|
||||
set cols [lrange [list xxx c0 c1 c2 c3 c4 c5 c6 c7] 1 $nCol]
|
||||
set data [lrange [list xxx \
|
||||
randomblob(4) randomblob(8) randomblob(16) randomblob(32) \
|
||||
randomblob(64) randomblob(128) randomblob(256) randomblob(512) \
|
||||
] 1 $nCol]
|
||||
|
||||
execsql { DROP TABLE IF EXISTS t1 }
|
||||
|
||||
db transaction {
|
||||
execsql "CREATE TABLE t1(a, [join $cols ,], b);"
|
||||
set insert "INSERT INTO t1 VALUES(:k, [join $data ,], :k)"
|
||||
for {set i 0} {$i < $nRow} {incr i} {
|
||||
set k [expr int(rand()*1000000000)]
|
||||
execsql $insert
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Helper for [do_sorter_test]
|
||||
#
|
||||
proc sorter_test {nRow nRead {nPayload 100} {cache_size 10}} {
|
||||
db eval "PRAGMA cache_size = $cache_size"
|
||||
set res [list]
|
||||
|
||||
set nLoad [expr ($nRow > $nRead) ? $nRead : $nRow]
|
||||
|
||||
set nPayload [expr (($nPayload+3)/4) * 4]
|
||||
set cols [list]
|
||||
foreach {mask col} {
|
||||
0x04 c0 0x08 c1 0x10 c2 0x20 c3
|
||||
0x40 c4 0x80 c5 0x100 c6 0x200 c7
|
||||
} {
|
||||
if {$nPayload & $mask} { lappend cols $col }
|
||||
}
|
||||
|
||||
set n 0
|
||||
db eval "SELECT a, [join $cols ,], b FROM t1 WHERE rowid<=$nRow ORDER BY a" {
|
||||
if {$a!=$b} { error "a!=b (a=$a b=$b)" }
|
||||
lappend res $a
|
||||
incr n
|
||||
if {$n==$nLoad} break
|
||||
}
|
||||
|
||||
|
||||
set sql {SELECT a FROM t1 WHERE rowid<=$nRow ORDER BY a LIMIT $nRead}
|
||||
if {$res != [db eval $sql]} {
|
||||
puts $res
|
||||
puts [db eval {SELECT a FROM t1 WHERE rowid<=$nLoad ORDER BY a}]
|
||||
error "data no good"
|
||||
}
|
||||
|
||||
set {} {}
|
||||
}
|
||||
|
||||
# Usage:
|
||||
#
|
||||
# do_sorter_test <testname> <args>...
|
||||
#
|
||||
# where <args> are any of the following switches:
|
||||
#
|
||||
# -rows N (number of rows to have sorter sort)
|
||||
# -read N (number of rows to read out of sorter)
|
||||
# -payload N (bytes of payload to read with each row)
|
||||
# -cachesize N (Value for "PRAGMA cache_size = ?")
|
||||
# -repeats N (number of times to repeat test)
|
||||
#
|
||||
proc do_sorter_test {tn args} {
|
||||
set a(-rows) 1000
|
||||
set a(-repeats) 1
|
||||
set a(-read) 100
|
||||
set a(-payload) 100
|
||||
set a(-cachesize) 100
|
||||
|
||||
foreach {s val} $args {
|
||||
if {[info exists a($s)]==0} {
|
||||
unset a(-cachesize)
|
||||
set optlist "[join [array names a] ,] or -cachesize"
|
||||
error "Unknown option $s, expected $optlist"
|
||||
}
|
||||
set a($s) $val
|
||||
}
|
||||
|
||||
for {set i 0} {$i < $a(-repeats)} {incr i} {
|
||||
set cmd [list sorter_test $a(-rows) $a(-read) $a(-payload) $a(-cachesize)]
|
||||
do_test $tn.$i $cmd {}
|
||||
}
|
||||
}
|
||||
|
||||
do_test 1 {
|
||||
execsql "PRAGMA page_size = 4096"
|
||||
populate_table 100000 500
|
||||
} {}
|
||||
|
||||
do_sorter_test 2 -repeats 10 -rows 1000 -read 100
|
||||
do_sorter_test 3 -repeats 10 -rows 100000 -read 1000
|
||||
do_sorter_test 4 -repeats 10 -rows 100000 -read 1000 -payload 500
|
||||
do_sorter_test 5 -repeats 10 -rows 100000 -read 100000 -payload 8
|
||||
do_sorter_test 6 -repeats 10 -rows 100000 -read 10 -payload 8
|
||||
|
||||
catch { db close }
|
||||
sqlite3_shutdown
|
||||
sqlite3_config_worker_threads 0
|
||||
sqlite3_initialize
|
||||
finish_test
|
||||
|
||||
|
Reference in New Issue
Block a user