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

18
LINES

< > BotCompany Repo | #1017087 // Measure size of non-Latin string [OK]

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

Libraryless. Click here for Pure Java version (1147L/8K/30K).

!7

p {
  for (int strlen = 4; strlen <= 40; strlen++) {
    Iterator<S> it = allWordsOfAlphabet_fixedLength("\u13a0\u13a1\u13a2\u13a3\u13a4\u13a5\u13a6\u13a7\u13a8\u13a9\u13aa\u13ab\u13ac\u13ad\u13ae\u13af", strlen);
    O[] array = new O[100000];
    long mem1 = usedMemoryAfterGC();
    for i over array: {
      assertTrue("Alphabet", it.hasNext());
      array[i] = it.next();
    }
    long mem2 = usedMemoryAfterGC();
    double objSize = (mem2-mem1)/(double) l(array);
    int rounded = iround(objSize);
    long f = guessStringSize(strlen);
    print("String length=" + strlen + ". Approximate object size: " + objSize + " => " + rounded + " bytes. Formula: " + f);
  }
}

Author comment

Began life as a copy of #1009423

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: #1017087
Snippet name: Measure size of non-Latin string [OK]
Eternal ID of this version: #1017087/1
Text MD5: 92bc1bbe4d9ab824356f6389fde321d4
Transpilation MD5: 59873ce242a3aa8f66f244b2b0dfa801
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-07-11 22:23:02
Source code size: 697 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 271 / 336
Referenced in: [show references]