]> gitweb.factorcode.org Git - factor.git/blob - extra/benchmark/dispatch4/dispatch4.factor
factor: trim using lists
[factor.git] / extra / benchmark / dispatch4 / dispatch4.factor
1 USING: kernel math sequences.private ;
2 IN: benchmark.dispatch4
3
4 : dispatch4 ( n -- val )
5     dup {
6         [ 0 eq? [ 0 ] [ "x" ] if ]
7         [ 1 eq? [ 1 ] [ "x" ] if ]
8         [ 2 eq? [ 2 ] [ "x" ] if ]
9         [ 3 eq? [ 3 ] [ "x" ] if ]
10         [ 4 eq? [ 4 ] [ "x" ] if ]
11         [ 5 eq? [ 5 ] [ "x" ] if ]
12         [ 6 eq? [ 6 ] [ "x" ] if ]
13         [ 7 eq? [ 7 ] [ "x" ] if ]
14         [ 8 eq? [ 8 ] [ "x" ] if ]
15         [ 9 eq? [ 9 ] [ "x" ] if ]
16         [ 10 eq? [ 10 ] [ "x" ] if ]
17         [ 11 eq? [ 11 ] [ "x" ] if ]
18         [ 12 eq? [ 12 ] [ "x" ] if ]
19         [ 13 eq? [ 13 ] [ "x" ] if ]
20         [ 14 eq? [ 14 ] [ "x" ] if ]
21         [ 15 eq? [ 15 ] [ "x" ] if ]
22         [ 16 eq? [ 16 ] [ "x" ] if ]
23         [ 17 eq? [ 17 ] [ "x" ] if ]
24         [ 18 eq? [ 18 ] [ "x" ] if ]
25         [ 19 eq? [ 19 ] [ "x" ] if ]
26     } dispatch ;
27
28 : dispatch4-benchmark ( -- )
29     20000000 [
30         20 [
31             dispatch4 drop
32         ] each-integer
33     ] times ;
34
35 MAIN: dispatch4-benchmark