Libraryless. Click here for Pure Java version (1155L/8K/30K).
!7 p { for (int strlen = 4; strlen <= 40; strlen++) { Iterator<S> it = allWordsOfAlphabet_fixedLength(lowerCaseAlphabet(), 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); } }
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, wtqryiryparv
No comments. add comment
| Snippet ID: | #1009423 |
| Snippet name: | Measure size of string [OK] |
| Eternal ID of this version: | #1009423/16 |
| Text MD5: | 78d293b9d1748def59bcf3c7be3eaf3f |
| Transpilation MD5: | 378d2fef0d1532fb2d718ececfa17851 |
| 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:10:36 |
| Source code size: | 618 bytes / 18 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 746 / 963 |
| Version history: | 15 change(s) |
| Referenced in: | #1009433 - Measure size of HashMap [gives a good rough estimate] #1017087 - Measure size of non-Latin string [OK] |