1
0
Fork 0

fix(plugin-timing): Clean up debug message

This commit is contained in:
Joost De Cock 2022-09-18 22:56:16 +02:00
parent 405808e2f9
commit 4ab4801940

View file

@ -1,14 +1,14 @@
import { name, version } from '../data.mjs'
const now = () => {
if (typeof window !== 'undefined') return window.performance.now() // Browser
if (typeof process !== 'undefined') return process.hrtime.bigint() // NodeJS
if (typeof window !== 'undefined') return window.performance.now() // Browser
if (typeof process !== 'undefined') return process.hrtime.bigint() // NodeJS
return false
}
const delta = (start) => {
if (typeof window !== 'undefined') return window.performance.now() - start // Browser
if (typeof process !== 'undefined') return( process.hrtime.bigint() - start)/BigInt(1000) // NodeJS
if (typeof window !== 'undefined') return window.performance.now() - start // Browser
if (typeof process !== 'undefined') return (process.hrtime.bigint() - start) / BigInt(1000) // NodeJS
return false
}
@ -22,13 +22,18 @@ export const plugin = {
},
prePartDraft: function (pattern) {
const time = now()
if (time) pattern.stores[pattern.activeSet].set(['timing', 'parts', pattern.activePart, 'start'], time)
if (time)
pattern.stores[pattern.activeSet].set(
['timing', 'parts', pattern.activePart, 'start'],
time
)
},
postPartDraft: function (pattern) {
const took = delta(pattern.stores[pattern.activeSet].get(['timing', 'parts', pattern.activePart, 'start']))
console.log(pattern.stores[pattern.activeSet].get(['timing', 'parts', pattern.activePart, 'start']))
if (took) pattern.stores[pattern.activeSet].set(['timing', 'parts', pattern.activePart, 'took'], took)
const took = delta(
pattern.stores[pattern.activeSet].get(['timing', 'parts', pattern.activePart, 'start'])
)
if (took)
pattern.stores[pattern.activeSet].set(['timing', 'parts', pattern.activePart, 'took'], took)
},
postDraft: function (pattern) {
const took = delta(pattern.stores[pattern.activeSet].get(['timing', 'draft', 'start']))
@ -40,4 +45,3 @@ export const plugin = {
// More specifically named exports
export const timingPlugin = plugin
export const pluginTiming = plugin