File tree Expand file tree Collapse file tree 2 files changed +24
-10
lines changed Expand file tree Collapse file tree 2 files changed +24
-10
lines changed Original file line number Diff line number Diff line change 1- ( function profileMethodCall ( ) {
2- var object = window . primesApp ;
3- console . assert ( object , 'cannot find object to profile' ) ;
1+ ( function profileMethodCall ( root ) {
2+ 'use strict' ;
43
4+ var name = 'primesApp' ;
55 var methodName = 'findFirstPrimes' ;
6+
7+ var object = root [ name ] ;
8+ console . assert ( object , 'cannot find object ' + name + ' to profile' ) ;
9+
610 var originalMethod = object [ methodName ] ;
711 console . assert ( typeof originalMethod === 'function' , 'cannot find method ' + methodName ) ;
12+
813 object [ methodName ] = function ( ) {
914 console . profile ( methodName ) ;
1015 originalMethod . call ( object ) ;
1116 console . profileEnd ( methodName ) ;
12- // restore original methodName
17+
1318 object [ methodName ] = originalMethod ;
19+ console . log ( 'restored the original method call' ) ;
1420 } ;
15- } ( ) ) ;
21+ console . log ( 'wrapped' , name + '.' + methodName + ' in profiling calls' ) ;
22+ } ( this ) ) ;
Original file line number Diff line number Diff line change 1- ( function timeMethodCall ( ) {
2- var object = window . primesApp ;
3- console . assert ( object , 'cannot find object to profile' ) ;
1+ ( function timeMethodCall ( root ) {
2+ 'use strict' ;
43
4+ var name = 'primesApp' ;
55 var methodName = 'findFirstPrimes' ;
6+
7+ var object = root [ name ] ;
8+ console . assert ( object , 'cannot find object ' + name + ' to profile' ) ;
9+
610 var originalMethod = object [ methodName ] ;
711 console . assert ( typeof originalMethod === 'function' , 'cannot find method ' + methodName ) ;
12+
813 object [ methodName ] = function ( ) {
914 console . time ( methodName ) ;
1015 originalMethod . call ( object ) ;
1116 console . timeEnd ( methodName ) ;
12- // restore original methodName
17+
1318 object [ methodName ] = originalMethod ;
19+ console . log ( 'restored the original method call' ) ;
1420 } ;
15- } ( ) ) ;
21+ console . log ( 'wrapped' , name + '.' + methodName + ' in timing calls' ) ;
22+ } ( this ) ) ;
You can’t perform that action at this time.
0 commit comments