javascript - Chrome JS Profiler 和 "Not Optimized: Inlining Bailed Out"警告

标签 javascript warnings out inlining

我尝试使用记录 CPU 使用率的 Chrome JS Profiler 运行我的应用程序,我收到了一些警告,其中有一些“ForInStatement is not fast case”,我已经修复了,但我得到了“Inlining Bailed Out”警告,例如在这段代码中:

function display_loader(){
  for(i in obstacles){
    display(obstacles[i])
  }
}

这个函数基本上创建了一个障碍物(display(obstacles[i]) 绘制了障碍物的特定图像 - 由于上面提到的“ForInStatement”警告,两个单独的函数用于加载和代码)。

消息“Inlining Bailed Out”随机出现,尤其是当我玩超过一分钟时,它出现在 move_loader、display_loader 或 collision_loader 函数中。有时会,有时不会。

你能给我任何文字解释“这条消息的真正含义吗?”我在网上阅读了很多主题,并且了解“ForInStatement”逻辑,但我对内联保释一无所知。

另外,你能告诉我如何修复它吗?

谢谢!

最佳答案

通常,bailout 意味着函数无法优化。这可能来自不受支持的 JS 功能,例如 try/catch block 、for of 等,或者因为优化过程遇到了某些限制。

作为the docs总结:

Not all functions can be optimized. Some features prevent the optimizing compiler from running on a given function (a “bail-out”)

This article系列给出了一些很好的解释。基本上,内联对于良好的性能至关重要。但是函数并没有系统地内联,因为它有成本。通常,只有多次调用的函数才会被内联。

所以在你的情况下,我猜你的 display 函数中有一些东西阻止了优化。该消息不会直接弹出,因为该功能并不总是/直接选择进行优化:

One consequence of this optimization approach is that short-running programs [...] don't exit their warm-up phase and don't get optimized. In general it is not necessary to waste energy to optimize something that is only run for a very short time.

Furthermore, note that V8 uses a non-deterministic sampling profiler to detect hot functions. Performance can therefore vary wildly depending on which function is active during the profiling ticks.

进一步阅读 here .希望这会有所帮助。

关于javascript - Chrome JS Profiler 和 "Not Optimized: Inlining Bailed Out"警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24563628/

相关文章:

python - 索引越界 (Python)

time - Google Colab - 已完成但仍在运行?

Javascript条件语法,压缩多个条件

node.js - 无法消除 yarn 不正确的对等依赖警告

javascript - 如何在 JQuery 中对数据进行排序

erlang - 抑制 Erlang "unused function"警告

grails - [method] 操作接受类型为 [org...JSONObject] 的参数,该参数未使用 @Validateable 标记。

c# - 在方法中使用 c# out/ref 关键字 "return"> 1 项而不是对象有好处吗

从 HTML 调用以向下拉列表添加选项的 JavaScript 函数无法正常工作

javascript - Node JS 点击页面上的按钮