Skip to content
Browse files

:time fixes

  • Loading branch information...
1 parent 8a2e33f commit d7de060e889767b788c76977d5ce9e162da5647a @simonlindholm committed Jun 14, 2012
Showing with 14 additions and 13 deletions.
  1. +14 −13 extension/content/firebug/console/profiler.js
View
27 extension/content/firebug/console/profiler.js
@@ -273,6 +273,16 @@ Firebug.Profiler = Obj.extend(Firebug.Module,
var nowF = (precise ? "performance.now()" : "Date.now()");
var ret = "{ ";
+ // Declare a container for the timing state. We'd ideally declare
+ // it with 'let', but when stopped in the debugger, this is often
+ // impossible due to the script being run with an older JavaScript
+ // version (issue 2244). Thus, use the (hidden, used for rerun)
+ // '_firebug' global instead.
+ if (context.stopped)
+ ret += "if (!window._firebug) window._firebug = {}; ";
+ else
+ ret += "let _firebug = {}; ";
+
var timingOverhead = "0";
if (precise)
{
@@ -281,16 +291,6 @@ Firebug.Profiler = Obj.extend(Firebug.Module,
ret += [nowF, nowF].join("; ") + "; ";
ret += "document.getElementById('dummy'); ";
- // Declare a container for the timing state. We'd ideally
- // declare it with 'let', but when stopped in the debugger,
- // this is often impossible due to the script being run with
- // an older JavaScript version (issue 2244). Thus, use the
- // (hidden, used for rerun) '_firebug' global instead.
- if (context.stopped)
- ret += "if (!window._firebug) window._firebug = {}; ";
- else
- ret += "let _firebug = {}; ";
-
// performance.now() takes some time to run (~0.02ms on my
// machine); thus, save some consecutive timings so we can
// account for that. The actual overhead fluctuates, so use
@@ -362,10 +362,11 @@ Firebug.Profiler = Obj.extend(Firebug.Module,
times.splice(0, 3);
}
- if (times.length >= 10)
+ if (times.length >= 10 && times[0] >= (precise ? 0.03 : 5))
{
- // We have enough data to be able to throw out outliers.
- var edge = Math.floor(times.length * 0.2);
+ // We have enough data and relative precision to be able to throw
+ // out outliers.
+ var edge = Math.floor(times.length * 0.15);
times.sort(function(a, b) { return a - b; });
times = times.slice(edge, -edge);
}

0 comments on commit d7de060

Please sign in to comment.
Something went wrong with that request. Please try again.