1

I have some performance issues in my JavaScript, and I'm not having much success instrumenting it. One of the things I've tried is using firebug's profile tool. It reports that the top single call was to dojo's log(). Unhelpfully, it reports a line number from the compressed script, so I can't tell what's causing the problem. But it seem interesting that 70% of the lines in the profile report are for dojo's log() calls, so cumulatively, it must be spending an amazing amount of time there. Is there a way to turn off dojo logging?

The only visible logging is an entry that shows up every 1.5 seconds and that appears to be a keep alive for comet. I'm also using dojo's slider in one place, but I don't see any evidence that that's causing a performance hit.

What other tools should I use to try to identify performance hot spots in javascript? The portion of my code that is in JavaScript is not really very large, so it wouldn't surprise me if it was round trips to the server that are really causing the problem, but I don't know how to instrument that either.

3 Answers 3

1

You are likely using a compressed version of Dojo. If you change dojo.js to dojo.js.uncompressed.js, the profile information should show you much more accurate information.

1
  • I thought I had tried that and not gotten any more information. I'll try again.
    – PanCrit
    Commented Aug 18, 2009 at 16:36
0

If you are using Dojo 1.2 or higher you can use stripConsole=normal while making your build to automatically strip all log calls it makes. If you are not using the build system then that's probably the #1 thing you can do to improve performance.

Some links to get you started:

http://docs.dojocampus.org/build/index

http://docs.dojocampus.org/quickstart/custom-builds

2
  • I've browsed around dojotoolkit.org, and I don't see anything about building. Everything seems to assume you'll want to use a ready-made version. Can you give a pointer to the build directions and what to download?
    – PanCrit
    Commented Aug 12, 2009 at 16:59
  • I added the links. If you've never seen those docs: They're a little slow and not structured in the best probably way, but there's a lot of really good information in there.
    – Marijn
    Commented Aug 12, 2009 at 22:39
0

Try building your JavaScript too, using the Dojo builder. Also, remember that the slowest calls are DOM calls. So make sure you're not querying the DOM inside a loop when it could be moved outside.

5
  • Very slow? Compared to what? Last time I had this problem was in Dojo 0.4. The current version is 1.3. Commented Aug 14, 2009 at 7:58
  • It's very slow, compared to not using it. Of course generating nodes and objects directly via JavaScript will be faster than making Dojo parse the DOM first before creating anything.
    – aehlke
    Commented Aug 14, 2009 at 14:15
  • Either you have a huge DOM, or you measure the wrong thing. Did you try to surprise people in the Dojo mailing list with that? Commented Aug 16, 2009 at 3:50
  • If you're saying the parser is slow, you're saying that Dojo's CSS selector code is slow. If you're saying Dojo's CSS selector code is slow, you're saying that all CSS selector code is slow, as we've always been at the top of the pack. Look at any of the CSS profiling tests, look at the slowest test, see if that number is really high enough to matter.
    – pottedmeat
    Commented Aug 18, 2009 at 4:11
  • Sorry, I overstated it and haven't thoroughly tested the latest versions with respect to the parser. I just recalled reading that advice (avoid the parser to improve performance) from one of the Dojo contributors, but it must have been something old. Thanks for the correction.
    – aehlke
    Commented Aug 18, 2009 at 14:00

Not the answer you're looking for? Browse other questions tagged or ask your own question.