Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

30
LINES

< > BotCompany Repo | #1006458 // Search For ID Collision. Also: Demonstrate Java memory behavior

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (5567L/38K/126K).

!7

static int n = 100000;
sbool autoGC;
static long totalIDsMade;

p {
  logOutput2();
  
  // if we're second instance, set autoGC on
  if (hasBot(programID())) autoGC = true; else makeBot(programID());
  
  // Loop and make IDs!
  while licensed {
  
    // MAIN
    new HashSet<S> ids;
    for i to n: {
      S id = aGlobalID();
      if (!ids.add(id))
        fail("Collision!!!!!!");
    }
    assertEquals(n, l(ids));
    // MAIN
    
    totalIDsMade += n;
    printWithTime(n(ids, "ids") + " made without collision (" + toMillions(totalIDsMade) + "M total)");
    if (autoGC) gc();
  }
}

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: 547 / 716
Referenced in: [show references]