@@ -243,12 +243,13 @@ function startProfiling(request, enabled) {
243243 } ;
244244
245245 if ( enabled ) {
246+ currentRequestExtension . id = uuid . v4 ( ) ;
246247 currentRequestExtension . startDate = Date . now ( ) ;
247248 currentRequestExtension . startTime = process . hrtime ( ) ;
248249 currentRequestExtension . stopTime = null ;
249250 currentRequestExtension . stepGraph = makeStep ( request . path , currentRequestExtension . startTime , null ) ;
250- currentRequestExtension . id = uuid . v4 ( ) ;
251251 currentRequestExtension . customTimings = { } ;
252+ debug ( `Profiling started for ${ request . path } with id ${ currentRequestExtension . id } ` ) ;
252253 }
253254 currentRequestExtension . timeQuery = function ( ) {
254255 var args = Array . prototype . slice . call ( arguments , enabled ? 0 : 3 ) ;
@@ -284,6 +285,7 @@ function stopProfiling(request){
284285
285286 var extension = request . miniprofiler ;
286287 var time = process . hrtime ( ) ;
288+ debug ( `Profiling stopped for ${ request . path } with id ${ extension . id } ` ) ;
287289 if ( extension . stepGraph . parent != null ) {
288290 throw new Error ( 'profiling ended while still in a function, was left in [' + extension . stepGraph . name + ']' ) ;
289291 }
@@ -346,7 +348,7 @@ function step(name, request, call) {
346348 * to have ended the query.
347349 */
348350function timeQuery ( extension , type , query , executeFunction ) {
349- debug ( `timeQuery "${ type } " with command "${ query } "` ) ;
351+ debug ( `Started timed query "${ type } " with command "${ query } "` ) ;
350352
351353 var time = process . hrtime ( ) ;
352354 var startDate = Date . now ( ) ;
@@ -367,21 +369,17 @@ function timeQuery(extension, type, query, executeFunction) {
367369 } ;
368370 extension . stepGraph . customTimings [ type ] . push ( customTiming ) ;
369371
370- //Do we need this?
371- /*
372372 for ( var i = 0 ; i < params . length ; i ++ ) {
373- var param = params[i];
374373 if ( _ . isFunction ( params [ i ] ) ) {
374+ var param = params [ i ] ;
375375 params [ i ] = function ( ) {
376- //customTiming.stopTime = process.hrtime( );
377-
376+ debug ( `Stopped timed query " ${ type } " with command " ${ query } "` ) ;
377+ customTiming . stopTime = process . hrtime ( ) ;
378378 var ret = param . apply ( this , arguments ) ;
379-
380379 return ret ;
381380 } ;
382381 }
383382 }
384- */
385383
386384 var ret = executeFunction . apply ( this , params ) ;
387385
0 commit comments