关于性能:Angular 4 – Angular与–prod捆绑的速度要快多少

Angular 4 - How much faster is Angular bundled with --prod

由于我们在.NET/Angular Web应用程序中的软件架构不理想,我们可能无法为生产环境执行ng build(--prod)的捆绑。

我现在的问题是,与同一个与ng build --prod捆绑在一起的应用程序相比,装载SystemJS的角度应用程序的性能提高有多大?

是否有人进行了绩效评估?

我用以下测试应用程序尝试了它,并在开发人员控制台中读取了执行时间,但这并不真正可靠。Angular RealWorld示例应用程序

"SystemJS""捆绑产品"
…..1.9秒…..|……1.1s
…2.2秒…….|……1.4s
…..1.7秒…..|……1.3s
…..2.1秒…..|……1.0s
…..1.8秒…..|……1.1s
…..1.7秒…..|……1.15秒

…约1.68s…..|……~1.17s(平均秒)


ng build--prod创建一个"提前"包(https://angular.io/guide/aot-compiler),这意味着Angular编译器不必包含在生产包中。

正如在文档中所写,在下载大小方面有性能提升:

The compiler is roughly half of Angular itself, so omitting it dramatically reduces the application payload.

号

同时也增加了应用程序启动时间:

Faster rendering

With AOT, the browser downloads a pre-compiled version of the application. The browser loads executable code so it can render the application immediately, without waiting to compile the app first.

号

与JIT编译的应用程序相比,实际的收益取决于模板的数量及其大小。

Fewer asynchronous requests

The compiler inlines external HTML templates and CSS style sheets within the application JavaScript, eliminating separate ajax requests for those source files.

号