Performance Improvements

This commit is contained in:
Luis Fernando Molina committed 2020-02-12 18:40:33 +01:00
1 parent c270163a83
commit e8eaa7168f
5 files changed
+37 -22

No files matched your search

+13 -9
View File
@@ -73,8 +73,9 @@ function newAnimation () {
let mustExecute
// console.clear()
let row = 0
for (const [key, callBackFunction] of callBackFunctions.entries()) {
row++
switch (key) {
case 'Floating Space Physics':
chanceToExecute = 50
@@ -86,14 +87,13 @@ function newAnimation () {
}
}
let timeConsumed = 0
if (mustExecute === true) {
let t0 = performance.now()
callBackFunction()
let t1 = performance.now()
let timeConsumed = t1 - t0
timeConsumed = t1 - t0
if (key === 'Chart Space Draw') {
// console.log(key, (totalConsumption / totalCounter).toFixed(1))
if (Math.random() * 100 > 99) {
totalConsumption = 0
totalCounter = 0
@@ -109,11 +109,15 @@ function newAnimation () {
}
/* Performance Check */
for (const [key, timeConsumed] of performanceMap.entries()) {
let percentage = timeConsumed * 100 / totalTimeConsumed
if (key === 'Chart Space Draw') {
// console.log(key, percentage.toFixed(0))
if (SHOW_ANIMATION_PERFORMACE === true) {
row = 0
for (const [key, timeConsumed] of performanceMap.entries()) {
row++
labelToPrint = key + ' ' + timeConsumed.toFixed(4)
printLabel(labelToPrint, 10, 100 + row * 30, 1, 20, UI_COLOR.RED)
let percentage = timeConsumed * 100 / totalTimeConsumed
labelToPrint = key + ' ' + percentage.toFixed(1) + '%'
printLabel(labelToPrint, 300, 100 + row * 30, 1, 20, UI_COLOR.RED)
}
}
} else {