1 |
|
---|
2 | /*
|
---|
3 | * Copyright (c) 1996, 1997 by Doug Bell <dbell@shvn.com>. All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Redistribution and use in source and binary forms, with or without
|
---|
6 | * modification, are permitted provided that the following conditions
|
---|
7 | * are met:
|
---|
8 | * 1. Redistributions of source code must retain the above copyright
|
---|
9 | * notice, this list of conditions and the following disclaimer.
|
---|
10 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
11 | * notice, this list of conditions and the following disclaimer in the
|
---|
12 | * documentation and/or other materials provided with the distribution.
|
---|
13 | *
|
---|
14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
---|
15 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
---|
16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
---|
17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
---|
18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
---|
19 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
---|
20 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
---|
21 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
---|
22 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
---|
23 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
---|
24 | * SUCH DAMAGE.
|
---|
25 | */
|
---|
26 |
|
---|
27 |
|
---|
28 | // This file has been hacked to compile without the rest of the
|
---|
29 | // benchmark code.
|
---|
30 |
|
---|
31 | class OperatorBenchmark {
|
---|
32 |
|
---|
33 | public int getSampleCount() { return 0; }
|
---|
34 | public int getSampleMillis() { return 0; }
|
---|
35 | public boolean go;
|
---|
36 | public int useint[];
|
---|
37 | public void startTest () { }
|
---|
38 | public long finishTest () { return 0; }
|
---|
39 | public void startTimer (boolean b) { }
|
---|
40 | public void stopTimer (int a, int b) { }
|
---|
41 | public void report (String s) { }
|
---|
42 | public void println (String s) { }
|
---|
43 |
|
---|
44 | public int getTestTime () {
|
---|
45 | return (int) (100 * getSampleCount() * getSampleMillis()) / 1000;
|
---|
46 | }
|
---|
47 |
|
---|
48 | public int getRunningTime () {
|
---|
49 | return (int) (1.1 * getTestTime());
|
---|
50 | }
|
---|
51 |
|
---|
52 | public long runTest () {
|
---|
53 | int dummy1 = 0, dummy2 = 0, dummy3 = 0; // occupy implicit index slots
|
---|
54 | int cnt, ii;
|
---|
55 | byte b1 = 1, b2 = 2, b3 = 3;
|
---|
56 | short s1 = 1, s2 = 2, s3 = 3;
|
---|
57 | int i1 = 1, i2 = 2, i3 = 3;
|
---|
58 | long l1 = 1, l2 = 2, l3 = 3;
|
---|
59 | float f1 = 1, f2 = 2, f3 = 3;
|
---|
60 | double d1 = 1, d2 = 2, d3 = 3;
|
---|
61 |
|
---|
62 | startTest();
|
---|
63 |
|
---|
64 | println("--- byte operators, local vars");
|
---|
65 |
|
---|
66 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
67 | startTimer(true);
|
---|
68 | for (ii = 0; go; ii++)
|
---|
69 | b1++;
|
---|
70 | stopTimer(cnt, ii);
|
---|
71 | }
|
---|
72 | report("byte++");
|
---|
73 |
|
---|
74 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
75 | startTimer(true);
|
---|
76 | for (ii = 0; go; ii++)
|
---|
77 | b1 += b2;
|
---|
78 | stopTimer(cnt, ii);
|
---|
79 | }
|
---|
80 | report("byte += byte");
|
---|
81 |
|
---|
82 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
83 | startTimer(true);
|
---|
84 | for (ii = 0; go; ii++)
|
---|
85 | b1 = (byte) (b2 + b3);
|
---|
86 | stopTimer(cnt, ii);
|
---|
87 | }
|
---|
88 | report("byte = byte + byte");
|
---|
89 |
|
---|
90 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
91 | startTimer(true);
|
---|
92 | for (ii = 0; go; ii++)
|
---|
93 | b1 *= b2;
|
---|
94 | stopTimer(cnt, ii);
|
---|
95 | }
|
---|
96 | report("byte *= byte");
|
---|
97 |
|
---|
98 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
99 | startTimer(true);
|
---|
100 | for (ii = 0; go; ii++)
|
---|
101 | b1 = (byte) (b2 * b3);
|
---|
102 | stopTimer(cnt, ii);
|
---|
103 | }
|
---|
104 | report("byte = byte * byte");
|
---|
105 |
|
---|
106 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
107 | startTimer(true);
|
---|
108 | for (ii = 0; go; ii++)
|
---|
109 | b1 *= 2;
|
---|
110 | stopTimer(cnt, ii);
|
---|
111 | }
|
---|
112 | report("byte *= 2");
|
---|
113 |
|
---|
114 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
115 | startTimer(true);
|
---|
116 | for (ii = 0; go; ii++)
|
---|
117 | b1 <<= 1;
|
---|
118 | stopTimer(cnt, ii);
|
---|
119 | }
|
---|
120 | report("byte <<= 1");
|
---|
121 |
|
---|
122 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
123 | startTimer(true);
|
---|
124 | for (ii = 0; go; ii++)
|
---|
125 | b1 %= b2;
|
---|
126 | stopTimer(cnt, ii);
|
---|
127 | }
|
---|
128 | report("byte %= byte");
|
---|
129 |
|
---|
130 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
131 | startTimer(true);
|
---|
132 | for (ii = 0; go; ii++)
|
---|
133 | b1 = (byte) (b2 % b3);
|
---|
134 | stopTimer(cnt, ii);
|
---|
135 | }
|
---|
136 | report("byte = byte % byte");
|
---|
137 |
|
---|
138 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
139 | startTimer(true);
|
---|
140 | for (ii = 0; go; ii++)
|
---|
141 | b1 /= b2;
|
---|
142 | stopTimer(cnt, ii);
|
---|
143 | }
|
---|
144 | report("byte /= byte");
|
---|
145 |
|
---|
146 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
147 | startTimer(true);
|
---|
148 | for (ii = 0; go; ii++)
|
---|
149 | b1 = (byte) (b2 / b3);
|
---|
150 | stopTimer(cnt, ii);
|
---|
151 | }
|
---|
152 | report("byte = byte / byte");
|
---|
153 |
|
---|
154 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
155 | startTimer(true);
|
---|
156 | for (ii = 0; go; ii++)
|
---|
157 | b1 /= 2;
|
---|
158 | stopTimer(cnt, ii);
|
---|
159 | }
|
---|
160 | report("byte /= 2");
|
---|
161 |
|
---|
162 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
163 | startTimer(true);
|
---|
164 | for (ii = 0; go; ii++)
|
---|
165 | b1 >>= 1;
|
---|
166 | stopTimer(cnt, ii);
|
---|
167 | }
|
---|
168 | report("byte >>= 1");
|
---|
169 |
|
---|
170 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
171 | startTimer(true);
|
---|
172 | for (ii = 0; go; ii++)
|
---|
173 | b1 >>= i2;
|
---|
174 | stopTimer(cnt, ii);
|
---|
175 | }
|
---|
176 | report("byte >>= int");
|
---|
177 |
|
---|
178 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
179 | startTimer(true);
|
---|
180 | for (ii = 0; go; ii++)
|
---|
181 | b1 = (byte) (b2 >> i3);
|
---|
182 | stopTimer(cnt, ii);
|
---|
183 | }
|
---|
184 | report("byte = byte >> int");
|
---|
185 |
|
---|
186 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
187 | startTimer(true);
|
---|
188 | for (ii = 0; go; ii++)
|
---|
189 | b1 |= b2;
|
---|
190 | stopTimer(cnt, ii);
|
---|
191 | }
|
---|
192 | report("byte |= byte");
|
---|
193 |
|
---|
194 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
195 | startTimer(true);
|
---|
196 | for (ii = 0; go; ii++)
|
---|
197 | b1 = (byte) (b2 | b3);
|
---|
198 | stopTimer(cnt, ii);
|
---|
199 | }
|
---|
200 | report("byte = byte | byte");
|
---|
201 |
|
---|
202 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
203 | startTimer(true);
|
---|
204 | for (ii = 0; go; ii++)
|
---|
205 | b1 &= b2;
|
---|
206 | stopTimer(cnt, ii);
|
---|
207 | }
|
---|
208 | report("byte &= byte");
|
---|
209 |
|
---|
210 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
211 | startTimer(true);
|
---|
212 | for (ii = 0; go; ii++)
|
---|
213 | b1 = (byte) (b2 & b3);
|
---|
214 | stopTimer(cnt, ii);
|
---|
215 | }
|
---|
216 | report("byte = byte & byte");
|
---|
217 |
|
---|
218 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
219 | startTimer(true);
|
---|
220 | for (ii = 0; go; ii++)
|
---|
221 | b1 ^= b2;
|
---|
222 | stopTimer(cnt, ii);
|
---|
223 | }
|
---|
224 | report("byte ^= byte");
|
---|
225 |
|
---|
226 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
227 | startTimer(true);
|
---|
228 | for (ii = 0; go; ii++)
|
---|
229 | b1 = (byte) (b2 ^ b3);
|
---|
230 | stopTimer(cnt, ii);
|
---|
231 | }
|
---|
232 | report("byte = byte ^ byte");
|
---|
233 |
|
---|
234 |
|
---|
235 | println("--- short operators, local vars");
|
---|
236 |
|
---|
237 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
238 | startTimer(true);
|
---|
239 | for (ii = 0; go; ii++)
|
---|
240 | s1++;
|
---|
241 | stopTimer(cnt, ii);
|
---|
242 | }
|
---|
243 | report("short++");
|
---|
244 |
|
---|
245 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
246 | startTimer(true);
|
---|
247 | for (ii = 0; go; ii++)
|
---|
248 | s1 += s2;
|
---|
249 | stopTimer(cnt, ii);
|
---|
250 | }
|
---|
251 | report("short += short");
|
---|
252 |
|
---|
253 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
254 | startTimer(true);
|
---|
255 | for (ii = 0; go; ii++)
|
---|
256 | s1 = (short) (s2 + s3);
|
---|
257 | stopTimer(cnt, ii);
|
---|
258 | }
|
---|
259 | report("short = short + short");
|
---|
260 |
|
---|
261 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
262 | startTimer(true);
|
---|
263 | for (ii = 0; go; ii++)
|
---|
264 | s1 *= s2;
|
---|
265 | stopTimer(cnt, ii);
|
---|
266 | }
|
---|
267 | report("short *= short");
|
---|
268 |
|
---|
269 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
270 | startTimer(true);
|
---|
271 | for (ii = 0; go; ii++)
|
---|
272 | s1 = (short) (s2 * s3);
|
---|
273 | stopTimer(cnt, ii);
|
---|
274 | }
|
---|
275 | report("short = short * short");
|
---|
276 |
|
---|
277 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
278 | startTimer(true);
|
---|
279 | for (ii = 0; go; ii++)
|
---|
280 | s1 *= 2;
|
---|
281 | stopTimer(cnt, ii);
|
---|
282 | }
|
---|
283 | report("short *= 2");
|
---|
284 |
|
---|
285 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
286 | startTimer(true);
|
---|
287 | for (ii = 0; go; ii++)
|
---|
288 | s1 <<= 1;
|
---|
289 | stopTimer(cnt, ii);
|
---|
290 | }
|
---|
291 | report("short <<= 1");
|
---|
292 |
|
---|
293 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
294 | startTimer(true);
|
---|
295 | for (ii = 0; go; ii++)
|
---|
296 | s1 %= s2;
|
---|
297 | stopTimer(cnt, ii);
|
---|
298 | }
|
---|
299 | report("short %= short");
|
---|
300 |
|
---|
301 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
302 | startTimer(true);
|
---|
303 | for (ii = 0; go; ii++)
|
---|
304 | s1 = (short) (s2 % s3);
|
---|
305 | stopTimer(cnt, ii);
|
---|
306 | }
|
---|
307 | report("short = short % short");
|
---|
308 |
|
---|
309 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
310 | startTimer(true);
|
---|
311 | for (ii = 0; go; ii++)
|
---|
312 | s1 /= s2;
|
---|
313 | stopTimer(cnt, ii);
|
---|
314 | }
|
---|
315 | report("short /= short");
|
---|
316 |
|
---|
317 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
318 | startTimer(true);
|
---|
319 | for (ii = 0; go; ii++)
|
---|
320 | s1 = (short) (s2 / s3);
|
---|
321 | stopTimer(cnt, ii);
|
---|
322 | }
|
---|
323 | report("short = short / short");
|
---|
324 |
|
---|
325 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
326 | startTimer(true);
|
---|
327 | for (ii = 0; go; ii++)
|
---|
328 | s1 /= 2;
|
---|
329 | stopTimer(cnt, ii);
|
---|
330 | }
|
---|
331 | report("short /= 2");
|
---|
332 |
|
---|
333 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
334 | startTimer(true);
|
---|
335 | for (ii = 0; go; ii++)
|
---|
336 | s1 >>= 1;
|
---|
337 | stopTimer(cnt, ii);
|
---|
338 | }
|
---|
339 | report("short >>= 1");
|
---|
340 |
|
---|
341 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
342 | startTimer(true);
|
---|
343 | for (ii = 0; go; ii++)
|
---|
344 | s1 >>= i2;
|
---|
345 | stopTimer(cnt, ii);
|
---|
346 | }
|
---|
347 | report("short >>= int");
|
---|
348 |
|
---|
349 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
350 | startTimer(true);
|
---|
351 | for (ii = 0; go; ii++)
|
---|
352 | s1 = (short) (s2 >> i3);
|
---|
353 | stopTimer(cnt, ii);
|
---|
354 | }
|
---|
355 | report("short = short >> int");
|
---|
356 |
|
---|
357 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
358 | startTimer(true);
|
---|
359 | for (ii = 0; go; ii++)
|
---|
360 | s1 |= s2;
|
---|
361 | stopTimer(cnt, ii);
|
---|
362 | }
|
---|
363 | report("short |= short");
|
---|
364 |
|
---|
365 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
366 | startTimer(true);
|
---|
367 | for (ii = 0; go; ii++)
|
---|
368 | s1 = (short) (s2 | s3);
|
---|
369 | stopTimer(cnt, ii);
|
---|
370 | }
|
---|
371 | report("short = short | short");
|
---|
372 |
|
---|
373 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
374 | startTimer(true);
|
---|
375 | for (ii = 0; go; ii++)
|
---|
376 | s1 &= s2;
|
---|
377 | stopTimer(cnt, ii);
|
---|
378 | }
|
---|
379 | report("short &= short");
|
---|
380 |
|
---|
381 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
382 | startTimer(true);
|
---|
383 | for (ii = 0; go; ii++)
|
---|
384 | s1 = (short) (s2 & s3);
|
---|
385 | stopTimer(cnt, ii);
|
---|
386 | }
|
---|
387 | report("short = short & short");
|
---|
388 |
|
---|
389 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
390 | startTimer(true);
|
---|
391 | for (ii = 0; go; ii++)
|
---|
392 | s1 ^= s2;
|
---|
393 | stopTimer(cnt, ii);
|
---|
394 | }
|
---|
395 | report("short ^= short");
|
---|
396 |
|
---|
397 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
398 | startTimer(true);
|
---|
399 | for (ii = 0; go; ii++)
|
---|
400 | s1 = (short) (s2 ^ s3);
|
---|
401 | stopTimer(cnt, ii);
|
---|
402 | }
|
---|
403 | report("short = short ^ short");
|
---|
404 |
|
---|
405 |
|
---|
406 | println("--- int operators, local vars");
|
---|
407 |
|
---|
408 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
409 | startTimer(true);
|
---|
410 | for (ii = 0; go; ii++)
|
---|
411 | i1++;
|
---|
412 | stopTimer(cnt, ii);
|
---|
413 | }
|
---|
414 | report("int++");
|
---|
415 |
|
---|
416 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
417 | startTimer(true);
|
---|
418 | for (ii = 0; go; ii++)
|
---|
419 | i1 += i2;
|
---|
420 | stopTimer(cnt, ii);
|
---|
421 | }
|
---|
422 | report("int += int");
|
---|
423 |
|
---|
424 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
425 | startTimer(true);
|
---|
426 | for (ii = 0; go; ii++)
|
---|
427 | i1 = (i2 + i3);
|
---|
428 | stopTimer(cnt, ii);
|
---|
429 | }
|
---|
430 | report("int = int + int");
|
---|
431 |
|
---|
432 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
433 | startTimer(true);
|
---|
434 | for (ii = 0; go; ii++)
|
---|
435 | i1 *= i2;
|
---|
436 | stopTimer(cnt, ii);
|
---|
437 | }
|
---|
438 | report("int *= int");
|
---|
439 |
|
---|
440 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
441 | startTimer(true);
|
---|
442 | for (ii = 0; go; ii++)
|
---|
443 | i1 = (i2 * i3);
|
---|
444 | stopTimer(cnt, ii);
|
---|
445 | }
|
---|
446 | report("int = int * int");
|
---|
447 |
|
---|
448 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
449 | startTimer(true);
|
---|
450 | for (ii = 0; go; ii++)
|
---|
451 | i1 *= 2;
|
---|
452 | stopTimer(cnt, ii);
|
---|
453 | }
|
---|
454 | report("int *= 2");
|
---|
455 |
|
---|
456 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
457 | startTimer(true);
|
---|
458 | for (ii = 0; go; ii++)
|
---|
459 | i1 <<= 1;
|
---|
460 | stopTimer(cnt, ii);
|
---|
461 | }
|
---|
462 | report("int <<= 1");
|
---|
463 |
|
---|
464 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
465 | startTimer(true);
|
---|
466 | for (ii = 0; go; ii++)
|
---|
467 | i1 %= i2;
|
---|
468 | stopTimer(cnt, ii);
|
---|
469 | }
|
---|
470 | report("int %= int");
|
---|
471 |
|
---|
472 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
473 | startTimer(true);
|
---|
474 | for (ii = 0; go; ii++)
|
---|
475 | i1 = (i2 % i3);
|
---|
476 | stopTimer(cnt, ii);
|
---|
477 | }
|
---|
478 | report("int = int % int");
|
---|
479 |
|
---|
480 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
481 | startTimer(true);
|
---|
482 | for (ii = 0; go; ii++)
|
---|
483 | i1 /= i2;
|
---|
484 | stopTimer(cnt, ii);
|
---|
485 | }
|
---|
486 | report("int /= int");
|
---|
487 |
|
---|
488 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
489 | startTimer(true);
|
---|
490 | for (ii = 0; go; ii++)
|
---|
491 | i1 = (i2 / i3);
|
---|
492 | stopTimer(cnt, ii);
|
---|
493 | }
|
---|
494 | report("int = int / int");
|
---|
495 |
|
---|
496 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
497 | startTimer(true);
|
---|
498 | for (ii = 0; go; ii++)
|
---|
499 | i1 /= 2;
|
---|
500 | stopTimer(cnt, ii);
|
---|
501 | }
|
---|
502 | report("int /= 2");
|
---|
503 |
|
---|
504 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
505 | startTimer(true);
|
---|
506 | for (ii = 0; go; ii++)
|
---|
507 | i1 >>= 1;
|
---|
508 | stopTimer(cnt, ii);
|
---|
509 | }
|
---|
510 | report("int >>= 1");
|
---|
511 |
|
---|
512 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
513 | startTimer(true);
|
---|
514 | for (ii = 0; go; ii++)
|
---|
515 | i1 >>= i2;
|
---|
516 | stopTimer(cnt, ii);
|
---|
517 | }
|
---|
518 | report("int >>= int");
|
---|
519 |
|
---|
520 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
521 | startTimer(true);
|
---|
522 | for (ii = 0; go; ii++)
|
---|
523 | i1 = i2 >> i3;
|
---|
524 | stopTimer(cnt, ii);
|
---|
525 | }
|
---|
526 | report("int = int >> int");
|
---|
527 |
|
---|
528 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
529 | startTimer(true);
|
---|
530 | for (ii = 0; go; ii++)
|
---|
531 | i1 |= i2;
|
---|
532 | stopTimer(cnt, ii);
|
---|
533 | }
|
---|
534 | report("int |= int");
|
---|
535 |
|
---|
536 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
537 | startTimer(true);
|
---|
538 | for (ii = 0; go; ii++)
|
---|
539 | i1 = i2 | i3;
|
---|
540 | stopTimer(cnt, ii);
|
---|
541 | }
|
---|
542 | report("int = int | int");
|
---|
543 |
|
---|
544 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
545 | startTimer(true);
|
---|
546 | for (ii = 0; go; ii++)
|
---|
547 | i1 &= i2;
|
---|
548 | stopTimer(cnt, ii);
|
---|
549 | }
|
---|
550 | report("int &= int");
|
---|
551 |
|
---|
552 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
553 | startTimer(true);
|
---|
554 | for (ii = 0; go; ii++)
|
---|
555 | i1 = i2 & i3;
|
---|
556 | stopTimer(cnt, ii);
|
---|
557 | }
|
---|
558 | report("int = int & int");
|
---|
559 |
|
---|
560 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
561 | startTimer(true);
|
---|
562 | for (ii = 0; go; ii++)
|
---|
563 | i1 ^= i2;
|
---|
564 | stopTimer(cnt, ii);
|
---|
565 | }
|
---|
566 | report("int ^= int");
|
---|
567 |
|
---|
568 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
569 | startTimer(true);
|
---|
570 | for (ii = 0; go; ii++)
|
---|
571 | i1 = i2 ^ i3;
|
---|
572 | stopTimer(cnt, ii);
|
---|
573 | }
|
---|
574 | report("int = int ^ int");
|
---|
575 |
|
---|
576 |
|
---|
577 | println("--- long operators, local vars");
|
---|
578 |
|
---|
579 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
580 | startTimer(true);
|
---|
581 | for (ii = 0; go; ii++)
|
---|
582 | l1++;
|
---|
583 | stopTimer(cnt, ii);
|
---|
584 | }
|
---|
585 | report("long++");
|
---|
586 |
|
---|
587 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
588 | startTimer(true);
|
---|
589 | for (ii = 0; go; ii++)
|
---|
590 | l1 += l2;
|
---|
591 | stopTimer(cnt, ii);
|
---|
592 | }
|
---|
593 | report("long += long");
|
---|
594 |
|
---|
595 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
596 | startTimer(true);
|
---|
597 | for (ii = 0; go; ii++)
|
---|
598 | l1 = (l2 + l3);
|
---|
599 | stopTimer(cnt, ii);
|
---|
600 | }
|
---|
601 | report("long = long + long");
|
---|
602 |
|
---|
603 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
604 | startTimer(true);
|
---|
605 | for (ii = 0; go; ii++)
|
---|
606 | l1 *= l2;
|
---|
607 | stopTimer(cnt, ii);
|
---|
608 | }
|
---|
609 | report("long *= long");
|
---|
610 |
|
---|
611 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
612 | startTimer(true);
|
---|
613 | for (ii = 0; go; ii++)
|
---|
614 | l1 = (l2 * l3);
|
---|
615 | stopTimer(cnt, ii);
|
---|
616 | }
|
---|
617 | report("long = long * long");
|
---|
618 |
|
---|
619 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
620 | startTimer(true);
|
---|
621 | for (ii = 0; go; ii++)
|
---|
622 | l1 *= 2;
|
---|
623 | stopTimer(cnt, ii);
|
---|
624 | }
|
---|
625 | report("long *= 2");
|
---|
626 |
|
---|
627 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
628 | startTimer(true);
|
---|
629 | for (ii = 0; go; ii++)
|
---|
630 | l1 <<= 1;
|
---|
631 | stopTimer(cnt, ii);
|
---|
632 | }
|
---|
633 | report("long <<= 1");
|
---|
634 |
|
---|
635 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
636 | startTimer(true);
|
---|
637 | for (ii = 0; go; ii++)
|
---|
638 | l1 %= l2;
|
---|
639 | stopTimer(cnt, ii);
|
---|
640 | }
|
---|
641 | report("long %= long");
|
---|
642 |
|
---|
643 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
644 | startTimer(true);
|
---|
645 | for (ii = 0; go; ii++)
|
---|
646 | l1 = (l2 % l3);
|
---|
647 | stopTimer(cnt, ii);
|
---|
648 | }
|
---|
649 | report("long = long % long");
|
---|
650 |
|
---|
651 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
652 | startTimer(true);
|
---|
653 | for (ii = 0; go; ii++)
|
---|
654 | l1 /= l2;
|
---|
655 | stopTimer(cnt, ii);
|
---|
656 | }
|
---|
657 | report("long /= long");
|
---|
658 |
|
---|
659 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
660 | startTimer(true);
|
---|
661 | for (ii = 0; go; ii++)
|
---|
662 | l1 = (l2 / l3);
|
---|
663 | stopTimer(cnt, ii);
|
---|
664 | }
|
---|
665 | report("long = long / long");
|
---|
666 |
|
---|
667 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
668 | startTimer(true);
|
---|
669 | for (ii = 0; go; ii++)
|
---|
670 | l1 /= 2;
|
---|
671 | stopTimer(cnt, ii);
|
---|
672 | }
|
---|
673 | report("long /= 2");
|
---|
674 |
|
---|
675 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
676 | startTimer(true);
|
---|
677 | for (ii = 0; go; ii++)
|
---|
678 | l1 >>= 1;
|
---|
679 | stopTimer(cnt, ii);
|
---|
680 | }
|
---|
681 | report("long >>= 1");
|
---|
682 |
|
---|
683 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
684 | startTimer(true);
|
---|
685 | for (ii = 0; go; ii++)
|
---|
686 | l1 >>= i2;
|
---|
687 | stopTimer(cnt, ii);
|
---|
688 | }
|
---|
689 | report("long >>= int");
|
---|
690 |
|
---|
691 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
692 | startTimer(true);
|
---|
693 | for (ii = 0; go; ii++)
|
---|
694 | l1 = l2 >> i3;
|
---|
695 | stopTimer(cnt, ii);
|
---|
696 | }
|
---|
697 | report("long = long >> int");
|
---|
698 |
|
---|
699 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
700 | startTimer(true);
|
---|
701 | for (ii = 0; go; ii++)
|
---|
702 | l1 |= l2;
|
---|
703 | stopTimer(cnt, ii);
|
---|
704 | }
|
---|
705 | report("long |= long");
|
---|
706 |
|
---|
707 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
708 | startTimer(true);
|
---|
709 | for (ii = 0; go; ii++)
|
---|
710 | l1 = l2 | l3;
|
---|
711 | stopTimer(cnt, ii);
|
---|
712 | }
|
---|
713 | report("long = long | long");
|
---|
714 |
|
---|
715 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
716 | startTimer(true);
|
---|
717 | for (ii = 0; go; ii++)
|
---|
718 | l1 &= l2;
|
---|
719 | stopTimer(cnt, ii);
|
---|
720 | }
|
---|
721 | report("long &= long");
|
---|
722 |
|
---|
723 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
724 | startTimer(true);
|
---|
725 | for (ii = 0; go; ii++)
|
---|
726 | l1 = l2 & l3;
|
---|
727 | stopTimer(cnt, ii);
|
---|
728 | }
|
---|
729 | report("long = long & long");
|
---|
730 |
|
---|
731 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
732 | startTimer(true);
|
---|
733 | for (ii = 0; go; ii++)
|
---|
734 | l1 ^= l2;
|
---|
735 | stopTimer(cnt, ii);
|
---|
736 | }
|
---|
737 | report("long ^= long");
|
---|
738 |
|
---|
739 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
740 | startTimer(true);
|
---|
741 | for (ii = 0; go; ii++)
|
---|
742 | l1 = l2 ^ l3;
|
---|
743 | stopTimer(cnt, ii);
|
---|
744 | }
|
---|
745 | report("long = long ^ long");
|
---|
746 |
|
---|
747 |
|
---|
748 | println("--- float operators, local vars");
|
---|
749 |
|
---|
750 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
751 | startTimer(true);
|
---|
752 | for (ii = 0; go; ii++)
|
---|
753 | f1 += f2;
|
---|
754 | stopTimer(cnt, ii);
|
---|
755 | }
|
---|
756 | report("float += float");
|
---|
757 |
|
---|
758 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
759 | startTimer(true);
|
---|
760 | for (ii = 0; go; ii++)
|
---|
761 | f1 = (float) (f2 + f3);
|
---|
762 | stopTimer(cnt, ii);
|
---|
763 | }
|
---|
764 | report("float = float + float");
|
---|
765 |
|
---|
766 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
767 | startTimer(true);
|
---|
768 | for (ii = 0; go; ii++)
|
---|
769 | f1 *= f2;
|
---|
770 | stopTimer(cnt, ii);
|
---|
771 | }
|
---|
772 | report("float *= float");
|
---|
773 |
|
---|
774 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
775 | startTimer(true);
|
---|
776 | for (ii = 0; go; ii++)
|
---|
777 | f1 = (float) (f2 * f3);
|
---|
778 | stopTimer(cnt, ii);
|
---|
779 | }
|
---|
780 | report("float = float * float");
|
---|
781 |
|
---|
782 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
783 | startTimer(true);
|
---|
784 | for (ii = 0; go; ii++)
|
---|
785 | f1 %= f2;
|
---|
786 | stopTimer(cnt, ii);
|
---|
787 | }
|
---|
788 | report("float %= float");
|
---|
789 |
|
---|
790 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
791 | startTimer(true);
|
---|
792 | for (ii = 0; go; ii++)
|
---|
793 | f1 = (float) (f2 % f3);
|
---|
794 | stopTimer(cnt, ii);
|
---|
795 | }
|
---|
796 | report("float = float % float");
|
---|
797 |
|
---|
798 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
799 | startTimer(true);
|
---|
800 | for (ii = 0; go; ii++)
|
---|
801 | f1 /= f2;
|
---|
802 | stopTimer(cnt, ii);
|
---|
803 | }
|
---|
804 | report("float /= float");
|
---|
805 |
|
---|
806 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
807 | startTimer(true);
|
---|
808 | for (ii = 0; go; ii++)
|
---|
809 | f1 = (float) (f2 / f3);
|
---|
810 | stopTimer(cnt, ii);
|
---|
811 | }
|
---|
812 | report("float = float / float");
|
---|
813 |
|
---|
814 |
|
---|
815 | println("--- double operators, local vars");
|
---|
816 |
|
---|
817 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
818 | startTimer(true);
|
---|
819 | for (ii = 0; go; ii++)
|
---|
820 | d1 += d2;
|
---|
821 | stopTimer(cnt, ii);
|
---|
822 | }
|
---|
823 | report("double += double");
|
---|
824 |
|
---|
825 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
826 | startTimer(true);
|
---|
827 | for (ii = 0; go; ii++)
|
---|
828 | d1 = (d2 + d3);
|
---|
829 | stopTimer(cnt, ii);
|
---|
830 | }
|
---|
831 | report("double = double + double");
|
---|
832 |
|
---|
833 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
834 | startTimer(true);
|
---|
835 | for (ii = 0; go; ii++)
|
---|
836 | d1 *= d2;
|
---|
837 | stopTimer(cnt, ii);
|
---|
838 | }
|
---|
839 | report("double *= double");
|
---|
840 |
|
---|
841 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
842 | startTimer(true);
|
---|
843 | for (ii = 0; go; ii++)
|
---|
844 | d1 = (d2 * d3);
|
---|
845 | stopTimer(cnt, ii);
|
---|
846 | }
|
---|
847 | report("double = double * double");
|
---|
848 |
|
---|
849 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
850 | startTimer(true);
|
---|
851 | for (ii = 0; go; ii++)
|
---|
852 | d1 %= d2;
|
---|
853 | stopTimer(cnt, ii);
|
---|
854 | }
|
---|
855 | report("double %= double");
|
---|
856 |
|
---|
857 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
858 | startTimer(true);
|
---|
859 | for (ii = 0; go; ii++)
|
---|
860 | d1 = (d2 % d3);
|
---|
861 | stopTimer(cnt, ii);
|
---|
862 | }
|
---|
863 | report("double = double % double");
|
---|
864 |
|
---|
865 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
866 | startTimer(true);
|
---|
867 | for (ii = 0; go; ii++)
|
---|
868 | d1 /= d2;
|
---|
869 | stopTimer(cnt, ii);
|
---|
870 | }
|
---|
871 | report("double /= double");
|
---|
872 |
|
---|
873 | for (cnt = getSampleCount(); --cnt >= 0; ) {
|
---|
874 | startTimer(true);
|
---|
875 | for (ii = 0; go; ii++)
|
---|
876 | d1 = (d2 / d3);
|
---|
877 | stopTimer(cnt, ii);
|
---|
878 | }
|
---|
879 | report("double = double / double");
|
---|
880 |
|
---|
881 | useint[0] = dummy1; useint[1] = dummy2; useint[2] = dummy3;
|
---|
882 | return finishTest();
|
---|
883 | }
|
---|
884 | } // class OperatorBenchmark
|
---|
885 |
|
---|
886 | // EOF
|
---|