12

So tried my hand at profiling some code and I figured the easiest way to do it (at least on Firefox) was to use either console's time/timeEnd or profile/profileEnd, and I tried both.

The problem I have is with the number of runs I can do before Firefox crashes on me. Now I won't paste the code here because it's typical benchmarking code (and it's very messy), but obviously the gist of it is that it runs functions (a test is represented with a function), logging their execution time for a certain number of runs.

Now with for example, 5e4 it sorta works but I don't think it's enough to spot (very) micro optimizations, but more than that, it crashes.

So how do you profile your JavaScript? Because this way, it's barely feasible.

5 Answers 5

2

When I used to profile my JavaScript code I used Chrome's profiler; the JavaScript Console in the developer view gives it, and it pretty much worked for me. Have you ever tried it?

Sign up to request clarification or add additional context in comments.

2 Comments

But did it crash your Chrome when profiling with a significantly large number of runs? That's the point.
Sorry not to have specified it before. I didn't really push it to its limits, so I cannot really answer here, but I suggest you give it a try.
2

I have tried profiling a page with a lot of scripting in Firebug on FF4 and the same in Chrome (last version). Firefox crashed within a second or two, Chrome didn't seem to have problems with it. Maybe you can find something on it in the Firebug issues list?

3 Comments

But it's not really an issue with Firebug. My loops are crashing Firefox, not Firebug's profiler.
My loops weren't crashing FB until I ran the Firebug profiler, so I would say it's a combination.
Well, I tried it with both Firebug installed and uninstalled. And also, if Firebug's the cause, why does it also crash in Chrome and IE?
1

Although not a traditional code profiler, I recommend Google's Speed Tracer:

Using Speed Tracer you are able to get a better picture of where time is being spent in your application. This includes problems caused by JavaScript parsing and execution, layout, CSS style recalculation and selector matching, DOM event handling, network resource loading, timer fires, XMLHttpRequest callbacks, painting, and more.

Comments

0

I think the profiler in the JavaScript Debugger (aka Venkman) is quite good. The version currently on addons.mozilla.org is not compatible with Firefox 4, but the change necessary to make it work has been committed. See https://bugzilla.mozilla.org/show_bug.cgi?id=614557 for details.

2 Comments

Meh, not available for Firefox 4.0.1 :<
You can get the 4.0-compatible version from Mercurial. See the linked bugzilla page (just updated) for more information.
0

dynaTrace AJAX edition(free)- one more tool in your bag. Offers a little bit more detailed performance metrics, IMHO. They used to have it only for IE, but their new one supports FF too. Also see Steve Sounder's blog

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.