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

32
LINES

< > BotCompany Repo | #1024426 // Bench LogNArray

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

Download Jar. Libraryless. Click here for Pure Java version (14832L/102K).

1  
!7
2  
3  
!include once #1024427 // LogNArray v4
4  
5  
p-exp {
6  
  new LogNArray<Int> a;
7  
  int n = 5000000;
8  
  
9  
  int[] random = new int[n];
10  
  for i to n: random[i] = random(n);
11  
  
12  
  twice { time {
13  
    a.clear();
14  
    for i to n: a.add(random[i]);
15  
  }}
16  
  printBenchResult("Adding", n);
17  
  
18  
  twice { time {
19  
    for i to n: a.get(i);
20  
  }}
21  
  printBenchResult("Accessing in order", n);
22  
  
23  
  twice { time {
24  
    for i to n: a.get(random[i]);
25  
  }}
26  
  printBenchResult("Accessing in random order", n);
27  
  
28  
  /*twice*/ { time {
29  
    for i to n: { a.remove(mod(random[i], l(a))); }
30  
  }}
31  
  printBenchResult("Removing in random order (without warm-up)", n);
32  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1024426
Snippet name: Bench LogNArray
Eternal ID of this version: #1024426/13
Text MD5: 44d08196453f8c432b345575a5a4c1ef
Transpilation MD5: 3a8cf8cb9388502b9ff222df90713983
Author: stefan
Category: javax
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-12 14:37:38
Source code size: 660 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 329 / 978
Version history: 12 change(s)
Referenced in: [show references]