From f97a3e9719c8fa04c1c4be725ad22fdc872779dc Mon Sep 17 00:00:00 2001 From: Jim Geurts Date: Thu, 15 Sep 2016 16:03:27 -0500 Subject: [PATCH 1/2] Check existence of start/stop parameters --- lib/miniprofiler.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/miniprofiler.js b/lib/miniprofiler.js index 086be80..b3c024c 100755 --- a/lib/miniprofiler.js +++ b/lib/miniprofiler.js @@ -406,6 +406,10 @@ function describePerformance(root, request) { } function diff(start, stop){ + if (!start || !stop) { + return 0; + } + var deltaSecs = stop[0] - start[0]; var deltaNanoSecs = stop[1] - start[1]; From 1e8c2dac0944ff70186c7625b2bec125855cece0 Mon Sep 17 00:00:00 2001 From: Jim Geurts Date: Fri, 16 Sep 2016 15:52:11 -0500 Subject: [PATCH 2/2] Use process.hrtime() when stop is undefined --- lib/miniprofiler.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/miniprofiler.js b/lib/miniprofiler.js index b3c024c..1e771df 100755 --- a/lib/miniprofiler.js +++ b/lib/miniprofiler.js @@ -406,8 +406,8 @@ function describePerformance(root, request) { } function diff(start, stop){ - if (!start || !stop) { - return 0; + if (!stop) { + stop = process.hrtime(); } var deltaSecs = stop[0] - start[0];