Libraryless. Click here for Pure Java version (427L/4K/12K).
!7 static int n = 20000; p { for (int tableSize = 0; tableSize < 200; tableSize += 20) { new L data; for i to tableSize: data.add(i); O[] array = new O[n]; long mem1 = usedMemoryAfterGC(); for i over array: { new TreeMap map; for (O x : data) map.put(x, x); array[i] = map; } long mem2 = usedMemoryAfterGC(); double objSize = (mem2-mem1)/(double) l(array); int rounded = iround(objSize); long f = guessTreeMapSize(tableSize); bool ok = rounded == f; print((ok ? "OK " : "") + "Hash table size=" + tableSize + ". Approximate object size: " + objSize + " => " + rounded + " bytes. Formula: " + f); } }
Began life as a copy of #1009433
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1009442 |
Snippet name: | Measure size of TreeMap [gives astonishingly good estimates] |
Eternal ID of this version: | #1009442/4 |
Text MD5: | 13818ab8e574fbf966182bc7be5636fb |
Transpilation MD5: | e41024ccbc7033030470f81c4f8e3af5 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-08-01 20:11:58 |
Source code size: | 693 bytes / 23 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 399 / 486 |
Version history: | 3 change(s) |
Referenced in: | -