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