Libraryless. Click here for Pure Java version (4773L/27K).
1 | !7 |
2 | |
3 | static int n = 100000; |
4 | |
5 | p { |
6 | for (int tableSize = 0; tableSize <= 10; tableSize ++) { |
7 | O[] data = arrayOfBlankObjects(tableSize); |
8 | O[] array = new O[n]; |
9 | long mem1 = usedMemoryAfterGC(); |
10 | for i over array: { |
11 | var map = Collections.synchronizedMap(new LinkedHashMap); |
12 | for (O x : data) map.put(x, x); |
13 | array[i] = map; |
14 | } |
15 | long mem2 = usedMemoryAfterGC(); |
16 | double objSize = (mem2-mem1)/(double) l(array); |
17 | int rounded = iround(objSize); |
18 | print("Object size=" + tableSize + ". Approximate object size: " + objSize + " => " + rounded + " bytes"); |
19 | } |
20 | } |
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: | 146 / 233 |
Version history: | 4 change(s) |
Referenced in: | [show references] |