-
Notifications
You must be signed in to change notification settings - Fork 3
/
calculator.html
110 lines (99 loc) · 3.36 KB
/
calculator.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!doctype html>
<html lang="en">
<head>
<title>meisterplan/jdk-base Memory Calculator</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
</head>
<style>
body {
font-family: sans-serif, "Roboto";
}
ul li {
display: flex;
flex-wrap: wrap;
align-items: center;
}
ul > li > label {
flex: 1 0 120px;
max-width: 180px;
}
</style>
<body>
<h2>Memory Calculator</h2>
<div style="width:600px;">
<p>Enter any values, either <em>Heap</em> or <em>Container Memory</em> is computed, if possible.</p>
<form>
<ul>
<li>
<label for="heap">Heap:</label>
<input type="number" id="heap"/> MiB
</li>
<li>
<label for="classes">Class Count:</label>
<input type="number" id="classes"/> Classes
</li>
<li>
<label for="threads">Thread Count:</label>
<input type="number" id="threads"/> Threads
</li>
<li style="border-top:1px solid black; margin: 1em 0"></li>
<li>
<label for="containermem">Container Memory:</label>
<input type="number" id="containermem"/> MiB
</li>
</ul>
</form>
<script>
const calculate = (changed) => {
const heap = $("#heap");
const classes = $("#classes");
const threads = $("#threads");
const containerMem = $("#containermem");
const computeHeap = () => Math.round(Number(containerMem.val()) * 0.85 - (264 + Number(threads.val()) + 0.00553131103 * Number(classes.val())));
const computeContainerMem = () => Math.round((264 + Number(heap.val()) + Number(threads.val()) + 0.00553131103 * Number(classes.val())) / 0.85);
if (changed.is(heap)) {
if (classes.val() && threads.val()) {
containerMem.val(computeContainerMem());
}
} else if (changed.is(classes)) {
if (heap.val()) {
containerMem.val(computeContainerMem());
} else if (classes.val() && threads.val()) {
heap.val(computeHeap());
}
} else if (changed.is(threads)) {
if (heap.val()) {
containerMem.val(computeContainerMem());
} else if (classes.val() && threads.val()) {
heap.val(computeHeap());
}
} else if (changed.is(containerMem)) {
if (classes.val() && threads.val()) {
heap.val(computeHeap());
}
}
}
$("#heap").keyup(function () {
calculate($(this))
}).change(function () {
calculate($(this))
});
$("#classes").keyup(function () {
calculate($(this))
}).change(function () {
calculate($(this))
});
$("#threads").keyup(function () {
calculate($(this))
}).change(function () {
calculate($(this))
});
$("#containermem").keyup(function () {
calculate($(this))
}).change(function () {
calculate($(this))
});
</script>
</div>
</body>
</html>