Firebug profiling issue: “no activity to profile”

…衆ロ難τιáo~ 提交于 2019-12-12 13:43:55

问题


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?


回答1:


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.




回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/2690697/firebug-profiling-issue-no-activity-to-profile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!