From e6bf344aece2dd02fcadce4f8eb58e9d76beb4af Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Sat, 10 Feb 2018 11:36:31 -0800 Subject: [PATCH] use custom perf mark impl --- package-lock.json | 5 ----- package.json | 1 - routes/_utils/marks.js | 17 ++++++++++++++--- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index c7cf27d4..6cc8ed47 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4639,11 +4639,6 @@ "object-visit": "1.0.1" } }, - "marky": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/marky/-/marky-1.2.0.tgz", - "integrity": "sha1-lhftZHu76o9F0ZUm2jPexwYG30I=" - }, "math-expression-evaluator": { "version": "1.2.17", "resolved": "https://registry.npmjs.org/math-expression-evaluator/-/math-expression-evaluator-1.2.17.tgz", diff --git a/package.json b/package.json index 41fd4cb8..35459d3b 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,6 @@ "intl-relativeformat": "^2.1.0", "lodash": "^4.17.4", "lodash-webpack-plugin": "^0.11.4", - "marky": "^1.2.0", "node-fetch": "^1.7.3", "node-sass": "^4.7.2", "npm-run-all": "^4.1.2", diff --git a/routes/_utils/marks.js b/routes/_utils/marks.js index dc2658e8..f354db6e 100644 --- a/routes/_utils/marks.js +++ b/routes/_utils/marks.js @@ -1,12 +1,23 @@ -import { mark as markyMark, stop as markyStop } from 'marky' import noop from 'lodash/noop' const enableMarks = process.browser && + performance.mark && (process.env.NODE_ENV !== 'production' || new URLSearchParams(location.search).get('marks') === 'true') -const mark = enableMarks ? markyMark : noop -const stop = enableMarks ? markyStop : noop +const perf = process.browser && performance + +function doMark(name) { + perf.mark(`start ${name}`) +} + +function doStop(name) { + perf.mark(`end ${name}`) + perf.measure(name, `start ${name}`, `end ${name}`) +} + +const mark = enableMarks ? doMark : noop +const stop = enableMarks ? doStop : noop export { mark,