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

17
LINES

< > BotCompany Repo | #1009436 // Measure size of ArrayList [OK]

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

Transpiled version (461L) is out of date.

!7

static int n = 100000;

p {
  for (int listSize = 90; listSize <= 100; listSize++) {
    O[] array = new O[n];
    long mem1 = usedMemoryAfterGC();
    for i over array: array[i] = rep(null, listSize);
    long mem2 = usedMemoryAfterGC();
    double objSize = (mem2-mem1)/(double) l(array);
    int rounded = iround(objSize);
    long f = guessArrayListSize(listSize);
    bool ok = rounded == f;
    print((ok ? "OK " : "") + "ArrayList size=" + listSize + ". Approximate object size: " + objSize + " => " + rounded + " bytes. Formula: " + f);
  }
}

Author comment

Began life as a copy of #1009433

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1009436
Snippet name: Measure size of ArrayList [OK]
Eternal ID of this version: #1009436/7
Text MD5: 53c6e3936dd7b10c68add45ed29b0654
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-08-01 04:31:49
Source code size: 570 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 348 / 501
Version history: 6 change(s)
Referenced in: [show references]