]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/benchmark/hashtables/hashtables.factor
factor: trim using lists
[factor.git] / extra / benchmark / hashtables / hashtables.factor
index 2ad485b5722bc5cc62728ce3aa08908b3b46b586..b29cb3d43d3e8a9686b623842a64bd8c23d0904f 100644 (file)
@@ -1,13 +1,11 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs combinators kernel locals math
-math.ranges memoize sequences strings hashtables
-math.parser grouping ;
-FROM: assocs => change-at ;
+USING: accessors assocs combinators grouping kernel math
+math.parser ranges sequences ;
 IN: benchmark.hashtables
 
 MEMO: strings ( -- str )
-    1 100 [a,b] 1 [ + ] accumulate nip [ number>string ] map ;
+    100 [0..b) 1 [ + ] accumulate* [ number>string ] map ;
 
 :: add-delete-mix ( hash keys -- )
     keys [| k |
@@ -33,7 +31,7 @@ MEMO: strings ( -- str )
     ] map drop
 
     keys [
-        hash [ 1 + ] change-at
+        hash [ 1 + ] assocs:change-at
     ] each ;
 
 : string-mix ( hash -- )
@@ -59,7 +57,7 @@ M: collision hashcode* value>> hashcode* 15 bitand ;
         2bi
     ] with each ;
 
-: hashtable-benchmark ( -- )
+: hashtables-benchmark ( -- )
     H{ } clone
     10000 [
         dup {
@@ -73,4 +71,4 @@ M: collision hashcode* value>> hashcode* 15 bitand ;
     ] times
     drop ;
 
-MAIN: hashtable-benchmark
+MAIN: hashtables-benchmark