console.time() in IE8 Developer Tools

Is there an equivalent to

console.time('');
console.timeEnd('');

in IE8 Developer Tools?

Answers


There isn't, but you can define it easily with JavaScript:

// console.time implementation for IE
if(window.console && typeof(window.console.time) == "undefined") {
    console.time = function(name, reset){
        if(!name) { return; }
        var time = new Date().getTime();
        if(!console.timeCounters) { console.timeCounters = {}; }
        var key = "KEY" + name.toString();
        if(!reset && console.timeCounters[key]) { return; }
            console.timeCounters[key] = time;
        };

    console.timeEnd = function(name){
        var time = new Date().getTime();
        if(!console.timeCounters) { return; }
        var key = "KEY" + name.toString();
        var timeCounter = console.timeCounters[key];
        var diff;
        if(timeCounter) {
            diff = time - timeCounter;
            var label = name + ": " + diff + "ms";
            console.info(label);
            delete console.timeCounters[key];
        }
        return diff;
    };
}

Just place it in your JS file before you want to use console.time() and console.timeEnd().

It is not my code, I actually copied it from Firebug core.


If you want to use Firebug in IE, there is a version called Firebug Lite, which can be used in any browser as a 'Bookmarklet'.

http://getfirebug.com/firebuglite

It isn't as functional as the real thing, but it can do a lot so it may be worth a try.


Need Your Help

iOS9 storyboard what is unhandled action (handleNonLaunchSpecificActions)?

error-handling uistoryboard ios9 xcode7 transition-coordinator

I've noticed the following error popping up in the console when running my app on iOS 9 when using a storyboard. I'm using xCode7. Is this something I need to be concerned about?

DropDownList's SelectedIndexChanged event not firing

asp.net drop-down-menu selectedindexchanged

I have a DropDownList object in my web page. When I click on it and select a different value, nothing happens, even though I have a function wired up to the SelectedIndexChanged event. I'll try and...