factor/apps/benchmarks/hashtables.factor

23 lines
566 B
Factor
Raw Permalink Normal View History

2005-11-24 19:02:20 -05:00
IN: temporary
2005-12-25 01:27:34 -05:00
USING: compiler hashtables kernel math memory namespaces
2005-11-24 19:02:20 -05:00
sequences strings test ;
2004-10-27 21:21:31 -04:00
2005-11-27 17:45:48 -05:00
: hash-bench-step ( hash elt -- )
3 random-int {
{ [ dup 0 = ] [ drop dup rot set-hash ] }
{ [ dup 1 = ] [ drop swap remove-hash ] }
{ [ dup 2 = ] [ drop swap hash drop ] }
} cond ;
2004-10-27 21:21:31 -04:00
2005-11-24 19:02:20 -05:00
: hashtable-benchmark ( seq -- )
2005-11-27 17:45:48 -05:00
10000 <hashtable> swap 10 [
2005-09-24 23:21:09 -04:00
drop
2005-11-27 17:45:48 -05:00
[
[
hash-bench-step
] each-with
] 2keep
] each 2drop ;
2004-10-27 21:21:31 -04:00
2005-11-24 19:02:20 -05:00
[ ] [ [ string? ] instances hashtable-benchmark ] unit-test