benchmark.splay: adding a splay-tree benchmark.
parent
ce1d69aa0a
commit
d773d99de5
|
@ -0,0 +1,18 @@
|
||||||
|
|
||||||
|
USING: arrays assocs kernel math.ranges random sequences sets
|
||||||
|
sorting trees.splay ;
|
||||||
|
|
||||||
|
IN: splay
|
||||||
|
|
||||||
|
: initial-alist ( n -- alist )
|
||||||
|
iota >array randomize dup zip ;
|
||||||
|
|
||||||
|
: change-random ( newkeys splay keys -- splay' )
|
||||||
|
swapd [ first pick delete-at first2 pick set-at ] 2each ;
|
||||||
|
|
||||||
|
: run-splay ( -- )
|
||||||
|
100,000 initial-alist 10,000 cut
|
||||||
|
[ >splay ] [ randomize 10,000 head ] bi
|
||||||
|
change-random keys dup natural-sort assert= ;
|
||||||
|
|
||||||
|
MAIN: run-splay
|
Loading…
Reference in New Issue