diff --git a/src/mol-task/util/user-timing.ts b/src/mol-task/util/user-timing.ts index fc64b57abf1f62ce6563f0bbb2e5920f2dc90c56..a4e3b7e33808f2dad86b1c59c929a85dda08a550 100644 --- a/src/mol-task/util/user-timing.ts +++ b/src/mol-task/util/user-timing.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. + * Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ @@ -7,17 +7,23 @@ import { Task } from '../task' const hasPerformance = typeof performance !== 'undefined' +/** + * on node `process.env.NODE_ENV` is available, in webpack build it is automatically set + * by the DefinePlugin to the webpack `mode` value + */ +const productionMode = process.env.NODE_ENV === 'production' +const timingEnabled = hasPerformance && !productionMode export namespace UserTiming { function startMarkName(task: Task<any>) { return `startTask${task.id}` } function endMarkName(task: Task<any>) { return `endTask${task.id}` } export function markStart(task: Task<any>) { - if (hasPerformance) performance.mark(startMarkName(task)) + if (timingEnabled) performance.mark(startMarkName(task)) } export function markEnd(task: Task<any>) { - if (hasPerformance) performance.mark(endMarkName(task)) + if (timingEnabled) performance.mark(endMarkName(task)) } export function measure(task: Task<any>) { - if (hasPerformance) performance.measure(task.name, startMarkName(task), endMarkName(task)) + if (timingEnabled) performance.measure(`✳️ ${task.name}`, startMarkName(task), endMarkName(task)) } } \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js index 3c8b6502aa99479f79962a3eaa96b98737e28a1d..0298bc8f7b726c2d45c12a3d1263e698b47d26d6 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -49,8 +49,6 @@ const sharedConfig = { }), new webpack.DefinePlugin({ __PLUGIN_VERSION_TIMESTAMP__: webpack.DefinePlugin.runtimeValue(() => `${new Date().valueOf()}`, true), - // include this for production version of React - // 'process.env.NODE_ENV': JSON.stringify('production') }), new MiniCssExtractPlugin({ filename: 'app.css' }) ],