| 16 | public class SizeMap |
| 17 | { |
| 18 | public static void main(String... __args) |
| 19 | { |
| 20 | for (int i = 0; i < 2048; i++) |
| 21 | { |
| 22 | double ii = (double)i; |
| 23 | double val; |
| 24 | |
| 25 | //val = Math.pow(2, Math.pow(2, Math.log(ii * 44.0))); |
| 26 | //val = Math.pow(2, ii); |
| 27 | |
| 28 | val = |
| 29 | // Base minimum size of all allocated objects |
| 30 | 8 + |
| 31 | |
| 32 | // Index counter multiplied to a multiple of four |
| 33 | (i * 4) + |
| 34 | |
| 35 | // Steady rise on the small scale |
| 36 | 1024 * (Math.max(0, i - 512)) + |
| 37 | |
| 38 | // Big rise on the large scale |
| 39 | 8192 * (Math.max(0, i - 1024)) + |
| 40 | |
| 41 | // Very big rise on the large scale |
| 42 | 65536 * (Math.max(0, i - 1536)) |
| 43 | |
| 44 | /*Math.min(134217727, 1 << ((i >>> 8) - 1)) +*/ |
| 45 | /*Math.min(268435455, 1 << ((i >>> 7) - 1)) +*/ |
| 46 | |
| 47 | // This one alone seems to work well |
| 48 | /*Math.max(0, Math.min(536870911, 1 << ((i >>> 6) - 1)))*/ |
| 49 | |
| 50 | ; |
| 51 | |
| 52 | // Base size, all objects and allocations are at least this size |
| 53 | val = 8; |
| 54 | |
| 55 | // Very small objects, the usual |
| 56 | if (i < 1024) |
| 57 | val += i * 4; |
| 58 | |
| 59 | // Smaller gains |
| 60 | else if (i < 1536) |
| 61 | val += 4096 + ((i - 1023) * 1024); |
| 62 | |
| 63 | // Larger gains |
| 64 | else if (i < 1792) |
| 65 | val += 528392 + ((i - 1535) * 4096); |
| 66 | |
| 67 | // Larger gains |
| 68 | else if (i < 2000) |
| 69 | val += 1576976 + ((i - 1791) * 214795); |
| 70 | |
| 71 | // The last amounts maximize usage |
| 72 | else if (i < 2048) |
| 73 | val += 2428944 + ((i - 1999) * 44040192); |
| 74 | |
| 75 | long x = (long)val; |