]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/benchmark/dispatch4/dispatch4.factor
factor: trim using lists
[factor.git] / extra / benchmark / dispatch4 / dispatch4.factor
index 685c92a8cc05a6a3e6277707b72293b0fcaa641e..4b127d4aa1a1b6932ae893f0dc85cb3b1be20ab8 100644 (file)
@@ -1,8 +1,7 @@
-USING: kernel.private kernel sequences math combinators
-sequences.private ;
+USING: kernel math sequences.private ;
 IN: benchmark.dispatch4
 
-: foobar-1 ( n -- val )
+: dispatch4 ( n -- val )
     dup {
         [ 0 eq? [ 0 ] [ "x" ] if ]
         [ 1 eq? [ 1 ] [ "x" ] if ]
@@ -26,42 +25,11 @@ IN: benchmark.dispatch4
         [ 19 eq? [ 19 ] [ "x" ] if ]
     } dispatch ;
 
-: foobar-2 ( n -- val )
-    {
-        { [ dup 0 eq? ] [ drop 0 ] }
-        { [ dup 1 eq? ] [ drop 1 ] }
-        { [ dup 2 eq? ] [ drop 2 ] }
-        { [ dup 3 eq? ] [ drop 3 ] }
-        { [ dup 4 eq? ] [ drop 4 ] }
-        { [ dup 5 eq? ] [ drop 5 ] }
-        { [ dup 6 eq? ] [ drop 6 ] }
-        { [ dup 7 eq? ] [ drop 7 ] }
-        { [ dup 8 eq? ] [ drop 8 ] }
-        { [ dup 9 eq? ] [ drop 9 ] }
-        { [ dup 10 eq? ] [ drop 10 ] }
-        { [ dup 11 eq? ] [ drop 11 ] }
-        { [ dup 12 eq? ] [ drop 12 ] }
-        { [ dup 13 eq? ] [ drop 13 ] }
-        { [ dup 14 eq? ] [ drop 14 ] }
-        { [ dup 15 eq? ] [ drop 15 ] }
-        { [ dup 16 eq? ] [ drop 16 ] }
-        { [ dup 17 eq? ] [ drop 17 ] }
-        { [ dup 18 eq? ] [ drop 18 ] }
-        { [ dup 19 eq? ] [ drop 19 ] }
-    } cond ;
-
-: foobar-test-1 ( -- )
-    20000000 [
-        20 [
-            foobar-1 drop
-        ] each-integer
-    ] times ;
-
-: foobar-test-2 ( -- )
+: dispatch4-benchmark ( -- )
     20000000 [
         20 [
-            foobar-2 drop
+            dispatch4 drop
         ] each-integer
     ] times ;
 
-MAIN: foobar-test-1
+MAIN: dispatch4-benchmark