factor/library/test/benchmark/hashtables.factor

21 lines
493 B
Factor

USE: strings
USE: kernel
USE: math
USE: test
USE: unparser
USE: hashtables
USE: compiler
! http://inferno.bell-labs.com/cm/cs/who/bwk/interps/pap.html
: store-hash ( hashtable n -- )
[ [ dup >hex swap pick set-hash ] keep ] repeat drop ; compiled
: lookup-hash ( hashtable n -- )
[ [ unparse over hash drop ] keep ] repeat drop ; compiled
: hashtable-benchmark ( n -- )
60000 <hashtable> swap 2dup store-hash lookup-hash ; compiled
[ ] [ 80000 hashtable-benchmark ] unit-test