Merge: doc: fixed some typos and other misc. corrections
[nit.git] / tests / bench_send2.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2004-2008 Jean Privat <jean@pryen.org>
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 redef class Object
18 fun foo do end
19 end
20 class A
21 redef fun foo do i += 1 end
22 init do end
23 var i = 0
24 end
25 class B
26 super A
27 redef fun foo do end
28 init do end
29
30 end
31 class C
32 super A
33 init do end
34
35 end
36 class D
37 super B
38 super C
39 init do end
40
41 end
42 class E
43 super B
44 super C
45 redef fun foo do end
46 init do end
47
48 end
49 class F
50 super D
51 super E
52 redef fun foo do end
53 init do end
54
55 end
56
57 var n = 10
58 if args.not_empty then n = args.first.to_i
59
60 var nb = 60
61 var a = new Array[Object].with_capacity(nb)
62 for i in [0..(nb/6)[ do
63 a[i*6] = new A
64 a[i*6+1] = new B
65 a[i*6+2] = new C
66 a[i*6+3] = new D
67 a[i*6+4] = new E
68 a[i*6+5] = new F
69 end
70 for i in [0..1 << n[ do
71 for j in [0..nb[ do
72 a[j].foo
73 end
74 end
75
76 for j in [0..nb[ do
77 print a[j].as(A).i
78 end