1 proc randstring
{min max
{type
binary}} {
2 set len
[expr {$min+int
(rand
()*($max-$min+1))}]
4 if {$type eq
{binary}} {
7 } elseif
{$type eq
{alpha
}} {
10 } elseif
{$type eq
{compr
}} {
15 append output
[format "%c" [expr {$minval+int
(rand
()*($maxval-$minval+1))}]]
21 # Useful for some test
22 proc zlistAlikeSort
{a b
} {
23 if {[lindex $a 0] > [lindex $b 0]} {return 1}
24 if {[lindex $a 0] < [lindex $b 0]} {return -1}
25 string compare
[lindex $a 1] [lindex $b 1]
28 # Return value for INFO property
29 proc status
{r property
} {
30 if {[regexp "\r\n$property:(.*?)\r\n" [$r info] _ value
]} {
35 proc waitForBgsave r
{
37 if {[status r bgsave_in_progress
] eq
1} {
38 puts -nonewline "\nWaiting for background save to finish... "
47 proc waitForBgrewriteaof r
{
49 if {[status r bgrewriteaof_in_progress
] eq
1} {
50 puts -nonewline "\nWaiting for background AOF rewrite to finish... "
59 proc randomInt
{max
} {
60 expr {int
(rand
()*$max)}
64 set path
[expr {int
(rand
()*[llength $args])}]
65 uplevel 1 [lindex $args $path]
70 # Small enough to likely collide
73 # 32 bit compressible signed/unsigned
74 randpath
{randomInt
2000000000} {randomInt
4000000000}
77 randpath
{randomInt
1000000000000}
80 randpath
{randstring
0 256 alpha
} \
81 {randstring
0 256 compr
} \
82 {randstring
0 256 binary}
88 # Small enough to likely collide
91 # 32 bit compressible signed/unsigned
92 randpath
{randomInt
2000000000} {randomInt
4000000000}
95 randpath
{randomInt
1000000000000}
98 randpath
{randstring
1 256 alpha
} \
99 {randstring
1 256 compr
}
103 proc createComplexDataset
{r ops
} {
104 for {set j
0} {$j < $ops} {incr j
} {
109 set d
[expr {rand
()}]
111 set d
[expr {rand
()}]
113 set d
[expr {rand
()}]
115 set d
[expr {rand
()}]
117 set d
[expr {rand
()}]
119 randpath
{set d
+inf
} {set d
-inf}
143 randpath
{$r lpush
$k $v} \
150 randpath
{$r sadd
$k $v} \
154 randpath
{$r zadd
$k $d $v} \
158 randpath
{$r hset
$k $f $v} \