Libraryless. Click here for Pure Java version (4773L/27K).
!7 static int n = 100000; p { for (int tableSize = 0; tableSize <= 10; tableSize ++) { O[] data = arrayOfBlankObjects(tableSize); O[] array = new O[n]; long mem1 = usedMemoryAfterGC(); for i over array: { var map = Collections.synchronizedMap(new LinkedHashMap); 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); print("Object size=" + tableSize + ". Approximate object size: " + objSize + " => " + rounded + " bytes"); } }
Began life as a copy of #1009433
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1034068 |
Snippet name: | Measure size of synchronized LinkedHashMap |
Eternal ID of this version: | #1034068/5 |
Text MD5: | 31feb1efe10f9d20fdc21621418c99a1 |
Transpilation MD5: | dfee5efac68305a6cbda8d8b55dc2c37 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-01-20 01:56:36 |
Source code size: | 614 bytes / 20 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 145 / 232 |
Version history: | 4 change(s) |
Referenced in: | [show references] |