1322
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger
|
|
3 |
|
|
4 |
New code and modifications done at SWING Research Group [1]:
|
|
5 |
|
|
6 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
|
|
7 |
SWING Research Group, Czech Technical University in Prague
|
|
8 |
|
|
9 |
This software is furnished under a license and may be used
|
|
10 |
only in accordance with the terms of that license and with the
|
|
11 |
inclusion of the above copyright notice. This software may not
|
|
12 |
be provided or otherwise made available to, or used by, any
|
|
13 |
other person. No title to or ownership of the software is
|
|
14 |
hereby transferred.
|
|
15 |
|
|
16 |
[1] Code written at SWING Research Group contains a signature
|
|
17 |
of one of the above copright owners. For exact set of such code,
|
|
18 |
see the differences between this version and version stx:libjava
|
|
19 |
as of 1.9.2010
|
|
20 |
"
|
|
21 |
"{ Package: 'stx:libjava/experiments' }"
|
|
22 |
|
|
23 |
"{ NameSpace: Benchmarks }"
|
|
24 |
|
|
25 |
Object subclass:#JavaLookup
|
|
26 |
instanceVariableNames:''
|
|
27 |
classVariableNames:''
|
|
28 |
poolDictionaries:''
|
|
29 |
category:'benchmarks-Misc'
|
|
30 |
!
|
|
31 |
|
|
32 |
Object subclass:#B2
|
|
33 |
instanceVariableNames:''
|
|
34 |
classVariableNames:''
|
|
35 |
poolDictionaries:''
|
|
36 |
privateIn:JavaLookup
|
|
37 |
!
|
|
38 |
|
|
39 |
!JavaLookup class methodsFor:'documentation'!
|
|
40 |
|
|
41 |
copyright
|
|
42 |
"
|
|
43 |
COPYRIGHT (c) 1996-2011 by Claus Gittinger
|
|
44 |
|
|
45 |
New code and modifications done at SWING Research Group [1]:
|
|
46 |
|
|
47 |
COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
|
|
48 |
SWING Research Group, Czech Technical University in Prague
|
|
49 |
|
|
50 |
This software is furnished under a license and may be used
|
|
51 |
only in accordance with the terms of that license and with the
|
|
52 |
inclusion of the above copyright notice. This software may not
|
|
53 |
be provided or otherwise made available to, or used by, any
|
|
54 |
other person. No title to or ownership of the software is
|
|
55 |
hereby transferred.
|
|
56 |
|
|
57 |
[1] Code written at SWING Research Group contains a signature
|
|
58 |
of one of the above copright owners. For exact set of such code,
|
|
59 |
see the differences between this version and version stx:libjava
|
|
60 |
as of 1.9.2010
|
|
61 |
|
|
62 |
"
|
|
63 |
! !
|
|
64 |
|
|
65 |
!JavaLookup class methodsFor:'benchmarks - direct'!
|
|
66 |
|
|
67 |
direct1
|
|
68 |
|
|
69 |
|b2|
|
|
70 |
|
|
71 |
b2 := B2 new.
|
|
72 |
Time millisecondsToRun: [
|
|
73 |
30000 timesRepeat:[
|
|
74 |
b2 method1.
|
|
75 |
].
|
|
76 |
].
|
|
77 |
|
|
78 |
"Created: / 26-12-2011 / 21:19:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
79 |
!
|
|
80 |
|
|
81 |
direct2
|
|
82 |
|
|
83 |
|b2|
|
|
84 |
|
|
85 |
b2 := B2 new.
|
|
86 |
Time millisecondsToRun: [
|
|
87 |
30000 timesRepeat:[
|
|
88 |
b2 method2.
|
|
89 |
].
|
|
90 |
].
|
|
91 |
|
|
92 |
"Created: / 26-12-2011 / 21:19:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
93 |
! !
|
|
94 |
|
|
95 |
!JavaLookup class methodsFor:'benchmarks - overload'!
|
|
96 |
|
|
97 |
overload1
|
|
98 |
|
|
99 |
|string integer boolean b1|
|
|
100 |
|
|
101 |
string := Java as_String: 's'.
|
|
102 |
integer := (Java as_Integer: 10).
|
|
103 |
boolean := (Java as_Boolean: true).
|
|
104 |
|
|
105 |
b1 := (Java classForName: 'stx.libjava.benchmarks.B1') new.
|
|
106 |
Time millisecondsToRun: [
|
|
107 |
10000 timesRepeat:[
|
|
108 |
b1 overload1: string.
|
|
109 |
b1 overload1: integer.
|
|
110 |
b1 overload1: boolean.
|
|
111 |
].
|
|
112 |
].
|
|
113 |
|
|
114 |
"Created: / 26-12-2011 / 21:14:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
115 |
!
|
|
116 |
|
|
117 |
overload2
|
|
118 |
|
|
119 |
|string b1|
|
|
120 |
|
|
121 |
string := Java as_String: 's'.
|
|
122 |
|
|
123 |
b1 := (Java classForName: 'stx.libjava.benchmarks.B1') new.
|
|
124 |
Time millisecondsToRun: [
|
|
125 |
30000 timesRepeat:[
|
|
126 |
b1 overload2: string.
|
|
127 |
].
|
|
128 |
].
|
|
129 |
|
|
130 |
"Created: / 26-12-2011 / 21:15:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
131 |
! !
|
|
132 |
|
|
133 |
!JavaLookup class methodsFor:'running'!
|
|
134 |
|
|
135 |
run: label
|
|
136 |
|
|
137 |
"
|
|
138 |
self run: 'Multiple dispatch'
|
|
139 |
"
|
|
140 |
| s |
|
|
141 |
s := "/'/home/jv/Research/PhD thesis/benchmarks/MOP.csv'
|
|
142 |
'/tmp/multiple_dispatch.csv'
|
|
143 |
asFilename appendStream.
|
|
144 |
[
|
|
145 |
#(
|
|
146 |
overload1
|
|
147 |
overload2
|
|
148 |
direct1
|
|
149 |
direct2
|
|
150 |
) do:
|
|
151 |
[:bench|
|
|
152 |
self put: label to: s.
|
|
153 |
self put: bench to: s.
|
|
154 |
6 timesRepeat:[self put: (self time: bench) to: s].
|
|
155 |
s cr].
|
|
156 |
] ensure:[
|
|
157 |
s close
|
|
158 |
]
|
|
159 |
|
|
160 |
"Created: / 02-08-2010 / 17:37:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
1347
|
161 |
"Modified: / 04-01-2012 / 21:37:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
1322
|
162 |
! !
|
|
163 |
|
|
164 |
!JavaLookup class methodsFor:'utils'!
|
|
165 |
|
|
166 |
put: o to: s
|
|
167 |
|
|
168 |
s nextPut:$".
|
|
169 |
o printOn: s.
|
|
170 |
s nextPut:$".
|
|
171 |
s nextPut:$,.
|
|
172 |
s space.
|
|
173 |
s flush
|
|
174 |
|
|
175 |
"Created: / 02-08-2010 / 17:35:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
176 |
!
|
|
177 |
|
|
178 |
time: bench
|
|
179 |
|
|
180 |
ObjectMemory flushCaches.
|
|
181 |
^Time millisecondsToRun:[20 timesRepeat:[self perform: bench]].
|
|
182 |
|
|
183 |
"Created: / 02-08-2010 / 17:39:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
184 |
! !
|
|
185 |
|
|
186 |
!JavaLookup::B2 methodsFor:'methods'!
|
|
187 |
|
|
188 |
method1
|
|
189 |
|
|
190 |
^1
|
|
191 |
|
|
192 |
"Created: / 26-12-2011 / 21:18:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
193 |
!
|
|
194 |
|
|
195 |
method2
|
|
196 |
|
|
197 |
^self method1
|
|
198 |
|
|
199 |
"Created: / 26-12-2011 / 21:18:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
200 |
! !
|
|
201 |
|
|
202 |
!JavaLookup class methodsFor:'documentation'!
|
|
203 |
|
|
204 |
version_SVN
|
|
205 |
^ '$Id$'
|
|
206 |
! !
|