简体   繁体   English

Vuejs 的性能指标

[英]Performance metrics for Vuejs

I'm looking for performance metrics for a Vue app.我正在寻找 Vue 应用程序的性能指标。 Metrics regarding the whole app but also for some specific components.有关整个应用程序的指标,但也适用于某些特定组件。

I know that I can use Vue.config.performance = true;我知道我可以使用Vue.config.performance = true; and then run the performance dev tools and maybe I could use something like Performance Observer in order to do specific things on new performance events.然后运行性能开发工具,也许我可以使用Performance Observer之类的东西来对新的性能事件做特定的事情。

I was wondering, if there are any libraries or services that could help or provide more metrics regarding the performance.我想知道是否有任何库或服务可以帮助或提供有关性能的更多指标。 The idea would be to have a ui with these metrics and could be visible for non-devs.我们的想法是拥有一个具有这些指标的用户界面,并且可以对非开发人员可见。

Any ideas?有任何想法吗?

You can use web-vitals library from the npm.您可以使用 npm 中的web- vitals 库。 It supports core web vitals metrics:它支持核心 web 生命体征指标:

Example will be looks like this:示例将如下所示:


import { getLCP, getFID, getCLS } from "web-vitals";

const reporter = (result) => console.log(result);

getCLS(reporter);
getFID(reporter);
getLCP(reporter);

Inside handler you can log the result to the console or send them your report system for further analysis.在处理程序内部,您可以将结果记录到控制台或将您的报告系统发送给他们以进行进一步分析。

It's also possible to get CDN version from here也可以从这里获取 CDN 版本

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

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