Q:

Detecting Javascript Memory Leaks & Optimizing Code

Similar to xdebug+webgrind which gives us the rough time for execution for each function in a file etc, I am wondering how to go about optimizing as well as detecting slow javascript functions. 
Am sure firebug can probably do this, but am not sure how? Can someone guide me as to how to detect memory leaks also? How do I decide if a function is too slow? I mean is there any benchmark, for e.g. in PHP i have a rough idea that any script which requires more than 200ms execution time, is kinda slow/maybe can be refactored. Roughly how many seconds should my code execute so that my browser experience is not sluggish? I know its a vague question... but are there any benchmarks?
Is there some kind of steps which I should follow before releasing code for public use?
Thank you very much for your time.

A:

I think that Fireunit's function call profiling would be the best solution for optimization.
http://ejohn.org/blog/function-call-profiling/

