Libraryless. Click here for Pure Java version (5567L/38K/126K).
1 | !7 |
2 | |
3 | static int n = 100000; |
4 | sbool autoGC; |
5 | static long totalIDsMade; |
6 | |
7 | p { |
8 | logOutput2(); |
9 | |
10 | // if we're second instance, set autoGC on |
11 | if (hasBot(programID())) autoGC = true; else makeBot(programID()); |
12 | |
13 | // Loop and make IDs! |
14 | while licensed { |
15 | |
16 | // MAIN |
17 | new HashSet<S> ids; |
18 | for i to n: { |
19 | S id = aGlobalID(); |
20 | if (!ids.add(id)) |
21 | fail("Collision!!!!!!"); |
22 | } |
23 | assertEquals(n, l(ids)); |
24 | // MAIN |
25 | |
26 | totalIDsMade += n; |
27 | printWithTime(n(ids, "ids") + " made without collision (" + toMillions(totalIDsMade) + "M total)"); |
28 | if (autoGC) gc(); |
29 | } |
30 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1006458 |
Snippet name: | Search For ID Collision. Also: Demonstrate Java memory behavior |
Eternal ID of this version: | #1006458/1 |
Text MD5: | 6e75532d42907171447327b884379860 |
Transpilation MD5: | 49747c46430a27020168517acd63c7eb |
Author: | stefan |
Category: | javax / maths |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-01-07 12:52:23 |
Source code size: | 626 bytes / 30 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 549 / 718 |
Referenced in: | [show references] |