File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed
packages/app/src/sandbox/utils Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change 11import _debug from '@codesandbox/common/lib/utils/debug' ;
2+ import { getGlobal } from '@codesandbox/common/lib/utils/global' ;
23
34const debug = _debug ( 'cs:compiler:measurements' ) ;
45
@@ -7,11 +8,16 @@ type MeasurementKey = string;
78const runningMeasurements = new Map < string , number > ( ) ;
89const measurements : { [ measurement : string ] : number } = { } ;
910
10- export function measure ( key : MeasurementKey ) {
11- if ( process . env . NODE_ENV !== 'production' ) {
12- return ;
13- }
11+ const global = getGlobal ( ) ;
12+ if ( typeof global . performance === 'undefined' ) {
13+ global . performance = {
14+ mark : ( ) => { } ,
15+ now : ( ) => Date . now ( ) ,
16+ measure : ( ) => { } ,
17+ } ;
18+ }
1419
20+ export function measure ( key : MeasurementKey ) {
1521 try {
1622 performance . mark ( `${ key } _start` ) ;
1723 runningMeasurements . set ( key , performance . now ( ) ) ;
@@ -27,10 +33,6 @@ export function endMeasure(
2733 lastTime ?: number ;
2834 } = { }
2935) {
30- if ( process . env . NODE_ENV !== 'production' ) {
31- return ;
32- }
33-
3436 try {
3537 const { lastTime } = options ;
3638 performance . mark ( `${ key } _end` ) ;
You can’t perform that action at this time.
0 commit comments