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

32
LINES

< > BotCompany Repo | #1024438 // Bench LogNArray (smaller array)

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

Download Jar. Libraryless. Click here for Pure Java version (7240L/51K).

1  
!7
2  
3  
!include once #1024427 // LogNArray v4
4  
5  
p-exp {
6  
  new LogNArray<Int> a;
7  
  int n = 100000;
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  
}

Author comment

Began life as a copy of #1024426

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1024438
Snippet name: Bench LogNArray (smaller array)
Eternal ID of this version: #1024438/1
Text MD5: 0a38853026d3891aa95d0c1e5e90780e
Transpilation MD5: a158ecedad285b19d77f4233ce694543
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 17:27:01
Source code size: 659 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 337 / 967
Referenced in: [show references]