Flex 性能注意事项

发布于 2024-10-20 21:54:40 字数 442 浏览 6 评论 0原文

为了提高 Flex 应用程序的性能,Flex 开发人员应该记住哪些主要要点? 我想到的是:

  1. 从更轻量级的基类扩展 ItemRenderers:即 UIComponent
  2. 动画
  3. 使用 suspendBackgroundProcessing 设置为 true,以便在适当的情况下使用 ArrayList 而不是 ArrayCollections 进行
  4. 。 Spark DataGroups 中的 useVirtualLayout(不幸的是,此步骤需要 Scrollers 才能使此建议有效)
  5. 针对 AIR 应用程序(事务等)的 SQLight 性能优化
  6. 可能会将长数据处理拆分为不同的帧? (虽然我从未这样做过,所以我可能会弄错)

在开发 Flex3/Flex4/AIR 应用程序以提高其性能时,您尝试遵循的关键准则是什么?

What are the main key-points a Flex developer should remember in order to improve performance of Flex applications?
The ones which come to my mind are:

  1. extending ItemRenderers from more lightweight base classes: i.e. UIComponent
  2. using suspendBackgroundProcessing set to true for animations
  3. using ArrayLists instead of ArrayCollections where appropriate.
  4. useVirtualLayout in Spark DataGroups (unfortunately this step requires Scrollers to make this advice effective)
  5. SQLight performance optimizations for AIR apps (transactions etc)
  6. Probably splitting long data processing into different frames? (Never done this though, so I might be mistaken)

What are the key guidelines you try to follow while developing your Flex3/Flex4/AIR applications in order to increase their performance?

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

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

发布评论

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

评论(4

汐鸠 2024-10-27 21:54:40

在我看来,很多人都存在 itemRenderer 的性能问题。所以,我的一个贡献是永远不要使用绑定 itemRenderer。我修复了很多客户的“内存泄漏”错误,只需重写他们的 itemRenderer 以使用 dataChange 事件而不是绑定。

除此之外,我赞同 @Wade Mueller 关于尽可能避免嵌套容器的评论。

It seems to me a lot of people have performance issues w/ itemRenderers. So, my one contribution here to never use binding an itemRenderer. I fix a lot of customer "memory leak" bugs just by rewriting their itemRenderers to use the dataChange event instead of binding.

Beyond that, I second @Wade Mueller's comment about avoiding nested containers as much as possible.

腻橙味 2024-10-27 21:54:40

尽管这对于重量较轻的 Spark Group 来说不太重要,但我总是尝试将嵌套容器的数量保持在最低限度,并在可能的情况下设置明确的位置/大小。具有相互嵌套的动态大小容器的复杂 UI 会导致必须进行大量(通常是不必要的)测量。这通常会导致在视图之间切换时出现巨大的滞后。

Although this is less important with the lighter weight Spark Groups, I always try to keep the number of nested containers to a minimum and set explicit positions/sizes when possible. Complicated UIs with dynamically sized containers nested within one another cause a ton of (usually unnecessary) measuring to have to occur. This often results in huge lags when switching between views.

恰似旧人归 2024-10-27 21:54:40

我的清单:

  • 尽可能使用本地变量而不是全局变量 尽可能
  • 使用 ActionScript 而不是 MXML
  • [Bindable] 生成大量代码,尽量避免

它Автор,а ты русский язык знаешь? :)

My list:

  • use local vars instead of global as much as possible
  • ActionScript instead of MXML as much as possible
  • [Bindable] generates tons of code, try to avoid it

P.S. Автор, а ты русский язык знаешь? :)

谜泪 2024-10-27 21:54:40

我考虑的主要事情(按重要性顺序排列):

  1. 绑定

  2. 验证(无效)调用是 Flex 中最昂贵的调用之一。使用它们时要小心。

    validateNow();

  3. 了解 Flex 组件生命周期。重写这些方法可以简化实例化过程。

  4. 使用向量对象。 更多信息

  5. 整数>数字。 非常好的答案

一些更基本的提示:

  1. 不要在循环中使用昂贵的操作。

    for(var i:int = 0; i < MassArray.length; i++)
    

    对于massiveArray(一个非常大的数组)来说,length() 可能是一个昂贵的操作。分配 var MassArrayLength:int = MassArray.length; 以提高性能。

  2. http://jacksondunstan.com/ 有大量有关优化代码的文章。这个人是个天才。

  3. 避免创建不必要的变量,因为实例化的成本很高。如果可能,请始终重用变量。

    function getComplexValue():int {
        var i:int = 复杂计算(); // 计算后返回int
        返回我;
    }
    

    相反,请立即返回。

    function getComplexValue():int {
        返回复杂计算();
    }
    
  4. 如果您有权访问它,Flash Profile 视角就是您的朋友。它是一个功能强大的分析器,可以减少优化代码库所需的时间。

The main things I consider, in order of importance:

  1. Binding

    • Creates a lot of extra code, and can cause a serious degradation in performance when bindings are not removed. For example, if you reuse components in an applications, listening functions are active throughout the entire flow of your application, consuming unnecessary memory and CPU cycles. For larger applications consider the BindingUtils class.

    • Note that you cannot unbind properties bound with curly braces {myVariable}

  2. Validate (invalidate) calls are some of the most expensive calls in Flex. Be careful when using them.

    validateNow();

  3. Understand the Flex component lifecycle. Overriding these methods can streamline the instantiation process.

  4. Use Vector objects. More information.

  5. Ints > Numbers. Excellent SO answer.

Some more basic tips:

  1. Do not use expensive operations in loops.

    for(var i:int = 0; i < massiveArray.length; i++)
    

    In the case of massiveArray, a very large array, length() might be an expensive operation. Assign var massiveArrayLength:int = massiveArray.length; to improve performance.

  2. http://jacksondunstan.com/ has a wealth of articles on optimizing your code. The man is a genius.

  3. Avoid creating unnecessary variables, as instantiation is expensive. Always reuse variables if possible.

    function getComplexValue():int {
        var i:int = complexCalculation(); // returns int after calculating
        return i;
    }
    

    Instead, just return immediately.

    function getComplexValue():int {
        return complexCalculation();
    }
    
  4. If you have access to it, the Flash Profile perspective is your friend. It's a powerful profiler that can reduce the time involved in optimizing a codebase.

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