3

I wrote a hefty script in JS and I want to optimize it to run faster, but going through function by function and performing a "speed test" is taking too long. Anyone know of a better way? I've heard you can use firebug, but I haven't found any helpful links of how to go about that..

The page I'm optimizing is here: http://flanvas.com/development/flanvas/examples/custom-class.html

I'm specifically trying to optimize the flanvas.js which is here: http://flanvas.com/development/flanvas/flanvas.js

Any direction of where to go from is very helpful. Thanks!

1

3 Answers 3

6

Use FireBug, or the Developer Tools in Safari or Chrome. In Safari/Chrome, go to the "Profiles" tab, click the "Enable Profiling" button, and hit the 'record' button. After you've done enough testing, hit it again to capture the profile.

You'll get a wonderful list breaking down your functions by the time they took, the time other functions that they called took, and multiple ways to sort it.

Rather than walk you through this, I'll give you some of the Google searches you should have done before asking this question:

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

1 Comment

Because it's always very handy when you search one of those, and then arrive at an answer telling you to search one of those. Thanks a lot.
3

You want to do profiling first for your javascript code to find which part of the code is the slowest. Of course, the main tool for that is firebug. Firebug is a very great tool for profiling.

You may also want to see this question for some more help: What is the best way to profile javascript execution?

3 Comments

Awesome. I just ran a "profile" on my script using firebug and it works just as I'd hoped. Thanks for the quick reply!
FYI it won't let me mark you as the answer so quickly. I'll mark it within the week.
It's OK. I'm glad I can help you :D
1

If you are using Firefox, firebug is a good tool, it can also give you some basic ideas on how to speed up javascript.

More at http://getfirebug.com/whatisfirebug

You can download it as JS code, and add it to your file if you are using other browser.

Still, there are other tools around, if that doesn't help... but it is a good start

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.