]> gitweb.factorcode.org Git - factor.git/blob - extra/benchmark/dispatch4/dispatch4.factor
Initial import
[factor.git] / extra / benchmark / dispatch4 / dispatch4.factor
1 USING: kernel.private kernel sequences math combinators ;
2 IN: benchmark.dispatch4
3
4 : foobar-1
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 : foobar-2
29     {
30         { [ dup 0 eq? ] [ drop 0 ] }
31         { [ dup 1 eq? ] [ drop 1 ] }
32         { [ dup 2 eq? ] [ drop 2 ] }
33         { [ dup 3 eq? ] [ drop 3 ] }
34         { [ dup 4 eq? ] [ drop 4 ] }
35         { [ dup 5 eq? ] [ drop 5 ] }
36         { [ dup 6 eq? ] [ drop 6 ] }
37         { [ dup 7 eq? ] [ drop 7 ] }
38         { [ dup 8 eq? ] [ drop 8 ] }
39         { [ dup 9 eq? ] [ drop 9 ] }
40         { [ dup 10 eq? ] [ drop 10 ] }
41         { [ dup 11 eq? ] [ drop 11 ] }
42         { [ dup 12 eq? ] [ drop 12 ] }
43         { [ dup 13 eq? ] [ drop 13 ] }
44         { [ dup 14 eq? ] [ drop 14 ] }
45         { [ dup 15 eq? ] [ drop 15 ] }
46         { [ dup 16 eq? ] [ drop 16 ] }
47         { [ dup 17 eq? ] [ drop 17 ] }
48         { [ dup 18 eq? ] [ drop 18 ] }
49         { [ dup 19 eq? ] [ drop 19 ] }
50     } cond ;
51
52 : foobar-test-1
53     20000000 [
54         20 [
55             foobar-1 drop
56         ] each
57     ] times ;
58
59 : foobar-test-2
60     20000000 [
61         20 [
62             foobar-2 drop
63         ] each
64     ] times ;
65
66 MAIN: foobar-test-1