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).

1  
!7
2  
3  
static int n = 1000000;
4  
5  
p {
6  
  new SecureRandom sr;
7  
  new Random r;
8  
  print("n=" + n);
9  
  
10  
  repeat 10 {
11  
    time "Random" {
12  
      repeat n { r.nextInt(); }
13  
    }
14  
    printBenchResult(n);
15  
  }
16  
  
17  
  repeat 10 {
18  
    time "Secure Random" {
19  
      repeat n { sr.nextInt(); }
20  
    }
21  
    printBenchResult(n);
22  
  }
23  
}

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: 450 / 910
Version history: 4 change(s)
Referenced in: [show references]