1 start_server
default.conf
{} {
2 test
{SORT ALPHA against integer encoded strings
} {
11 test
{Create a random
list and a random
set} {
14 for {set i
0} {$i < 10000} {incr i
} {
16 # Make sure all the weights are different because
17 # Redis does not use a stable sort but Tcl does.
19 set rint
[expr int
(rand
()*1000000)]
21 set rint
[expr rand
()]
23 if {![info exists seenrand
($rint)]} break
29 r hset wobj_
$i weight
$rint
30 lappend tosort
[list $i $rint]
32 set sorted
[lsort -index 1 -real $tosort]
34 for {set i
0} {$i < 10000} {incr i
} {
35 lappend res
[lindex $sorted $i 0]
40 test
{SORT with BY against the newly created
list} {
41 r sort tosort
{BY weight_
*}
44 test
{SORT with BY
(hash field
) against the newly created
list} {
45 r sort tosort
{BY wobj_
*->weight
}
48 test
{SORT with GET
(key
+hash
) with sanity check of each element
(list)} {
50 set l1
[r sort tosort GET
# GET weight_*]
51 set l2
[r sort tosort GET
# GET wobj_*->weight]
52 foreach {id1 w1
} $l1 {id2 w2
} $l2 {
53 set realweight
[r get weight_
$id1]
55 set err
"ID mismatch $id1 != $id2"
58 if {$realweight != $w1 ||
$realweight != $w2} {
59 set err
"Weights mismatch! w1: $w1 w2: $w2 real: $realweight"
66 test
{SORT with BY
, but against the newly created
set} {
67 r sort tosort-set
{BY weight_
*}
70 test
{SORT with BY
(hash field
), but against the newly created
set} {
71 r sort tosort-set
{BY wobj_
*->weight
}
74 test
{SORT with BY and STORE against the newly created
list} {
75 r sort tosort
{BY weight_
*} store sort-res
76 r
lrange sort-res
0 -1
79 test
{SORT with BY
(hash field
) and STORE against the newly created
list} {
80 r sort tosort
{BY wobj_
*->weight
} store sort-res
81 r
lrange sort-res
0 -1
84 test
{SORT direct
, numeric
, against the newly created
list} {
86 } [lsort -integer $res]
88 test
{SORT decreasing sort
} {
90 } [lsort -decreasing -integer $res]
92 test
{SORT speed
, sorting
10000 elements
list using BY
, 100 times
} {
93 set start
[clock clicks
-milliseconds]
94 for {set i
0} {$i < 100} {incr i
} {
95 set sorted
[r sort tosort
{BY weight_
* LIMIT
0 10}]
97 set elapsed
[expr [clock clicks
-milliseconds]-$start]
98 puts -nonewline "\n Average time to sort: [expr double($elapsed)/100] milliseconds "
103 test
{SORT speed
, as above but against hash field
} {
104 set start
[clock clicks
-milliseconds]
105 for {set i
0} {$i < 100} {incr i
} {
106 set sorted
[r sort tosort
{BY wobj_
*->weight LIMIT
0 10}]
108 set elapsed
[expr [clock clicks
-milliseconds]-$start]
109 puts -nonewline "\n Average time to sort: [expr double($elapsed)/100] milliseconds "
114 test
{SORT speed
, sorting
10000 elements
list directly
, 100 times
} {
115 set start
[clock clicks
-milliseconds]
116 for {set i
0} {$i < 100} {incr i
} {
117 set sorted
[r sort tosort
{LIMIT
0 10}]
119 set elapsed
[expr [clock clicks
-milliseconds]-$start]
120 puts -nonewline "\n Average time to sort: [expr double($elapsed)/100] milliseconds "
125 test
{SORT speed
, pseudo-sorting
10000 elements
list, BY
<const
>, 100 times
} {
126 set start
[clock clicks
-milliseconds]
127 for {set i
0} {$i < 100} {incr i
} {
128 set sorted
[r sort tosort
{BY nokey LIMIT
0 10}]
130 set elapsed
[expr [clock clicks
-milliseconds]-$start]
131 puts -nonewline "\n Average time to sort: [expr double($elapsed)/100] milliseconds "
136 test
{SORT regression
for issue
#19, sorting floats} {
138 foreach x
{1.1 5.10 3.10 7.44 2.1 5.75 6.12 0.25 1.15} {
142 } [lsort -real {1.1 5.10 3.10 7.44 2.1 5.75 6.12 0.25 1.15}]
144 test
{SORT with GET
#} {
149 r mset weight_1
10 weight_2
5 weight_3
30
150 r sort mylist BY weight_
* GET
#
153 test
{SORT with constant GET
} {
154 r sort mylist GET foo
157 test
{SORT against sorted sets
} {
164 r sort zset alpha desc
167 test
{Sorted sets
+inf and
-inf handling
} {
172 r zadd zset
1000000 d