mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 18:44:16 +00:00
use PerformanceLog
class
This commit is contained in:
parent
76fa2a3fd1
commit
ae0a480314
@ -7,59 +7,7 @@ import { SliderPicker } from "react-color"
|
|||||||
|
|
||||||
import { Icons, createIconRender } from "components/Icons"
|
import { Icons, createIconRender } from "components/Icons"
|
||||||
|
|
||||||
class PerformanceLog {
|
import PerformanceLog from "classes/PerformanceLog"
|
||||||
constructor(
|
|
||||||
id,
|
|
||||||
params = {
|
|
||||||
disabled: false
|
|
||||||
}
|
|
||||||
) {
|
|
||||||
this.id = id
|
|
||||||
this.params = params
|
|
||||||
|
|
||||||
this.table = {}
|
|
||||||
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
start(event) {
|
|
||||||
if (this.params.disabled) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.table[event]) {
|
|
||||||
this.table[event] = {}
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.table[event]["start"] = performance.now()
|
|
||||||
}
|
|
||||||
|
|
||||||
end(event) {
|
|
||||||
if (this.params.disabled) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.table[event]) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.table[event]["end"] = performance.now()
|
|
||||||
}
|
|
||||||
|
|
||||||
finally() {
|
|
||||||
if (this.params.disabled) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
console.group(this.id)
|
|
||||||
|
|
||||||
Object.entries(this.table).forEach(([entry, value]) => {
|
|
||||||
console.log(entry, `${(value.end - value.start).toFixed(0)}ms`)
|
|
||||||
})
|
|
||||||
|
|
||||||
console.groupEnd()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const SettingsComponents = {
|
export const SettingsComponents = {
|
||||||
button: {
|
button: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user