Skip to content

Commit 56fad2a

Browse files
author
Lukas Meier
committed
The user can now enable CPU stress to simulate an
FPS-Drop
1 parent 4cc68bc commit 56fad2a

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

index.html

+10-2
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,22 @@
1212
}
1313
#canvas{
1414
border: 1px solid #dedede;
15-
margin: 50px auto;
1615
display: block;
1716
background-color: #fff;
1817
box-shadow: 15px 15px 15px rgba(0,0,0,0.2);
18+
margin-bottom: 50px;
19+
}
20+
21+
#container{
22+
margin: 50px auto;
23+
width: 1000px;
1924
}
2025
</style>
2126
</head>
2227
<body>
23-
<canvas width="1000" height="500" id="canvas"></canvas>
28+
<div id="container">
29+
<canvas width="1000" height="500" id="canvas"></canvas>
30+
<input type="checkbox" id="stress"><label for="stress">Stress the CPU to simulate FPS-Drop?</label>
31+
</div>
2432
</body>
2533
</html>

js/main.js

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
window.onload = function () {
22
window["graph"] = new Graph();
3+
var stress = document.getElementById("stress");
4+
stress.onchange = function () {
5+
if (stress.checked) {
6+
window["graph"].dropFps = true;
7+
}
8+
else {
9+
window["graph"].dropFps = false;
10+
}
11+
};
312
};

ts/Graph.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ class Graph {
169169
this.drawDurationGraph();
170170
this.drawScrollPercentage();
171171
this.drawFps();
172+
172173
if (this.dropFps) {
173174
this.overload();
174175
}
@@ -319,7 +320,7 @@ class Graph {
319320
* to stress the CPU and drop the FPS
320321
* Call this in the draw() function
321322
*/
322-
overload() {
323+
overload(): void {
323324
this.songs.forEach(song => {
324325
for (let i = 0; i < 100; i++) {
325326
let sqrt = Math.sqrt(this.timeStringToSeconds(song.duration));

ts/main.ts

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
window.onload = () => {
22
window["graph"] = new Graph();
3+
const stress = document.getElementById("stress") as HTMLInputElement
4+
stress.onchange = () => {
5+
if(stress.checked){
6+
window["graph"].dropFps = true;
7+
}else{
8+
window["graph"].dropFps = false;
9+
}
10+
}
311
};

0 commit comments

Comments
 (0)