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

23
LINES

< > BotCompany Repo | #1010910 // Bench SecureRandom vs normal random - ~2 microseconds vs ~200 nanoseconds [OK]

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

Download Jar. Libraryless. Click here for Pure Java version (1238L/9K).

!7

static int n = 1000000;

p {
  new SecureRandom sr;
  new Random r;
  print("n=" + n);
  
  repeat 10 {
    time "Random" {
      repeat n { r.nextInt(); }
    }
    printBenchResult(n);
  }
  
  repeat 10 {
    time "Secure Random" {
      repeat n { sr.nextInt(); }
    }
    printBenchResult(n);
  }
}

Author comment

Began life as a copy of #1010909

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1010910
Snippet name: Bench SecureRandom vs normal random - ~2 microseconds vs ~200 nanoseconds [OK]
Eternal ID of this version: #1010910/5
Text MD5: aa72c92370f5b3f436f1eb4b2982694b
Transpilation MD5: f0682494fb0c8b2bbcce20b80cb464a8
Author: stefan
Category: javax / random
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-09-22 12:35:45
Source code size: 330 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 437 / 884
Version history: 4 change(s)
Referenced in: [show references]