Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebug profiling issue: "no activity to profile"

I want to try some different options with some javascript (jQuery) to see which is the fastest, however I can't get profiling working properly. Here is the code I want to test.

    $this.keypress(function(e) {
        console.profile("test");

        //retrieve the charcode if possible, otherwise get the keycode
        k = e.which ? e.which : e.CharCode;

        if (blockKeyCodes.indexOf("|" + k + "|") != -1 || e.ctrlKey && k == 86)
            e.preventDefault();

        console.profileEnd();
    });

However, when I run this the console states "no activity to profile". If I use console.time the result is 0ms.

Anyone know how to fix this?

like image 967
Alistair Avatar asked Feb 25 '26 13:02

Alistair


2 Answers

Firebug profiler does not give the time taken by native methods, wrap entire functionality into a function and call that function between profile start and end.

like image 178
Amareswar Avatar answered Feb 27 '26 03:02

Amareswar


I think you don't need to specify a name when starting the profile. Alternatively, have you tried console.time?

from http://getfirebug.com/logging

Firebug gives you two easy ways to measure JavaScript performance. The low-fi approach is to call console.time("timing foo") before the code you want to measure, and then console.timeEnd("timing foo") afterwards. Firebug will then log the time that was spent in between.

The high-fi approach is to use the JavaScript profiler. Just call console.profile() before the code you want to measure, and then console.profileEnd() afterwards. Firebug will log a detailed report about how much time was spent in every function call in between.

like image 20
Jasper De Bruijn Avatar answered Feb 27 '26 02:02

Jasper De Bruijn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!