puzzle/public/Debug.js

26 lines
417 B
JavaScript
Raw Normal View History

import { logger } from '../common/Util.js'
const log = logger('Debug.js')
2020-11-09 01:54:05 +01:00
let _pt = 0
let _mindiff = 0
const checkpoint_start = (mindiff) => {
_pt = performance.now()
_mindiff = mindiff
}
const checkpoint = (label) => {
2021-04-15 10:40:12 +02:00
const now = performance.now()
2020-11-09 01:54:05 +01:00
const diff = now - _pt
if (diff > _mindiff) {
2021-04-15 10:40:12 +02:00
log.log(label + ': ' + (diff))
2020-11-09 01:54:05 +01:00
}
2021-04-15 10:40:12 +02:00
_pt = now
2020-11-09 01:54:05 +01:00
}
export default {
checkpoint_start,
checkpoint,
}