Libraryless. Click here for Pure Java version (654L/5K/16K).
1 | !752 |
2 | |
3 | sclass A { |
4 | int a = 1, b = 2, c = 3, d = 4, e = 5, f = 6, g = 7, h = 8; |
5 | } |
6 | |
7 | sclass B { |
8 | int a = 1, b = 2, c = 3, d = 4, e = 5, f = 6, g = 7, h = 8; |
9 | int i = 9, j = 10, k = 11, l = 12, m = 13, n = 14; |
10 | } |
11 | |
12 | static final long rep = 1000000; |
13 | |
14 | static S[] letters = new S[27]; |
15 | |
16 | !include #1005583 // getOpt_cached |
17 | |
18 | p { |
19 | new A a; |
20 | new B b; |
21 | |
22 | for (int i = 1; i <= 26; i++) |
23 | letters[i] = str(alphabetLetter(i)); |
24 | |
25 | twice { |
26 | time { |
27 | for (long j = 0; j < rep; j++) { |
28 | for (int i = 1; i <= 8; i++) { |
29 | // Be mean - alternate between classes (different fields, same name) |
30 | assertTrue(i == (Int) getOpt(a, letters[i])); |
31 | assertTrue(i == (Int) getOpt(b, letters[i])); |
32 | } |
33 | } |
34 | } |
35 | |
36 | time { |
37 | for (long j = 0; j < rep; j++) { |
38 | for (int i = 1; i <= 8; i++) { |
39 | assertTrue(i == (Int) getOpt_cached(a, letters[i])); |
40 | assertTrue(i == (Int) getOpt_cached(b, letters[i])); |
41 | } |
42 | } |
43 | } |
44 | |
45 | long ms = getLastTiming(); |
46 | print(iterationsPerSecond(rep*8, ms) + " getOpt/s"); |
47 | } |
48 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1005581 |
Snippet name: | Benchmark getOpt + cached version |
Eternal ID of this version: | #1005581/1 |
Text MD5: | 9292bebeb123086aa26aec05be730a18 |
Transpilation MD5: | 4d981388979b5a911379198ead1ebebf |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-11-28 19:11:28 |
Source code size: | 1122 bytes / 48 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 504 / 624 |
Referenced in: | [show references] |