0.0.1 • Published 4 years ago

webperfscore v0.0.1

Weekly downloads
1
License
Apache-2.0
Repository
-
Last release
4 years ago

webperfscore

web 性能评分工具。

安装使用

  1. 安装依赖
npm install webperfscore --save 
  1. 运行计算

    import { webperfscore } from 'webperfscore';
    
    const result = webperfscore({
      'first-contentful-paint': 2000,
      'first-meaningful-paint': 2000,
      'speed-index': 3000,
      'fully-loaded': 4000,
    });
    
    console.log(result.score); // 分值
  2. 分析结果:webperfscore 默认采用 10 分制度。

    • 0-2 分:堪忧
    • 2-4 分:较差
    • 4-6 分:一般
    • 6-8 分:较好
    • 8-10 分:非常好

API

  • webperfscore(metrics, options):计算性能评分

    • metrics:性能指标值。metrics 是个 Map 对象,key 为指标名,value 为指标值。如果是时间,那么以毫秒为单位。
    • options:配置选项,可以决定评分总分值,以及各个性能指标的权重和得分计算,参考默认值
  • defaultScoreOptions:默认配置选项,总分默认 10 分。

  • defaultAudits:默认指标配置

0.0.1

4 years ago