简体   繁体   English

Xamarin Forms 与 Prism 和 DryIoc 有很多注册页面,会降低性能吗?

[英]Xamarin Forms with Prism and DryIoc with a lot of registered page, can reduce performance?

For example, we have a big Xamarin forms project, with 2000 page, and Prism MVVM framework, with DryIoc container, that has registered all 2000 pages.例如,我们有一个大的 Xamarin forms 项目,有 2000 个页面,还有一个 Prism MVVM 框架,带有 DryIoc 容器,已经注册了所有 2000 个页面。

This a lot of pages, added with DependencyService for example, navigationservice, dialogservice, can reduce navigation's speed and/or performance?这么多页面,添加了 DependencyService,例如,navigationservice、dialogservice,会降低导航的速度和/或性能吗? It can makes app run slow, for a lot of dependency?它可以使应用程序运行缓慢,因为很多依赖?

Thanks!!谢谢!!

There isn't a simple answer to this.对此没有简单的答案。 The general one is - yes.一般是 - 是的。 The DryIoc, like any package, is an additional overhead to your project.与任何 package 一样,DryIoc 是项目的额外开销。 The IoC container surely adds some time to the overall feeling. IoC 容器确实为整体感觉增加了一些时间。 Keep in mind that the overhead is minimal - in the matter of some milliseconds.请记住,开销是最小的 - 在几毫秒内。 Like it says in the GitHub repo :就像它在GitHub repo中所说的那样:

Designed for low-ceremony use, performance, and extensibility.专为低仪式使用、性能和可扩展性而设计。

DryIoc is considered to be a relatively fast container. DryIoc 被认为是一个相对较快的容器。 Here is the official IoC Container Benchmark - Performance comparison .这是官方的IoC Container Benchmark-Performance 比较

But again, it all depends on how many services you need to instantiate.但同样,这完全取决于您需要实例化多少服务。 It doesn't matter if you have 2000 pages.如果你有 2000 页也没关系。 It matters how many dependencies you will have with these pages and how many circular dependencies also.这些页面有多少依赖关系以及多少循环依赖关系也很重要。

Also, some of the IoC logic is being done on app start-up and you can also match some of the resolving there.此外,一些 IoC 逻辑是在应用程序启动时完成的,您也可以在那里匹配一些解析。

To sum up - it is better to have IoC container, than to not have one because the flexibility, that you get from it, beats the eventual small overhead of performance.总而言之 - 拥有 IoC 容器比没有容器要好,因为您从中获得的灵活性超过了最终的小幅性能开销。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM