dojo 的性能(日志记录、彗星、滑块)

发布于 2024-08-02 07:40:16 字数 420 浏览 3 评论 0原文

我的 JavaScript 存在一些性能问题,并且我在检测它方面没有取得太大成功。我尝试过的事情之一是使用 firebug 的配置文件工具。它报告最上面的单个调用是对 dojo 的 log() 的调用。无济于事的是,它报告压缩脚本中的行号,因此我无法判断是什么导致了问题。但有趣的是,配置文件报告中 70% 的行用于 dojo 的 log() 调用,因此累积起来,它一定在那里花费了惊人的时间。有没有办法关闭 dojo 日志记录?

唯一可见的日志记录是每 1.5 秒显示一次的条目,它似乎是彗星的保持活动状态。我还在一个地方使用了 dojo 的滑块,但我没有看到任何证据表明这会导致性能下降。

我还应该使用哪些其他工具来尝试识别 javascript 中的性能热点?我的 JavaScript 代码部分并不是很大,所以如果真正导致问题的是服务器的往返,我也不会感到惊讶,但我也不知道如何检测它。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

假装不在乎 2024-08-09 07:40:16

您可能正在使用 Dojo 的压缩版本。如果将 dojo.js 更改为 dojo.js.uncompressed.js,配置文件信息应该会显示更准确的信息。

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.

梦萦几度 2024-08-09 07:40:16

如果您使用的是 Dojo 1.2 或更高版本,则可以在构建时使用 stripConsole=normal 来自动删除其发出的所有日志调用。如果您不使用构建系统,那么这可能是您可以提高性能的第一件事。

一些帮助您入门的链接:

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

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

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

心在旅行 2024-08-09 07:40:16

也尝试使用 Dojo 构建器构建您的 JavaScript。另外,请记住最慢的调用是 DOM 调用。因此,请确保当 DOM 可以移出循环时,您不会在循环内查询 DOM。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文