开发者

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 cons开发者_运维知识库ole states "no activity to profile". If I use console.time the result is 0ms.

Anyone know how to fix this?


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.


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.


Do you turn on profiling before you run the code?

Click on Firebug > console > profile

You should see a message in firebug saying: "The profiler is running. Click 'Profile' again to see its report."

HTH

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜