All Projects → paulirish → Pwmetrics

paulirish / Pwmetrics

Licence: apache-2.0
Progressive web metrics at your fingertipz

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Pwmetrics

Garie
Open source web performance
Stars: ✭ 484 (-61.06%)
Mutual labels:  metrics, lighthouse, performance
Nemetric
前端性能指标的监控,采集以及上报。用于测量第一个dom生成的时间(FP/FCP/LCP)、用户最早可操作时间(fid|tti)和组件的生命周期性能,,网络状况以及资源大小等等。向监控后台报告实际用户测量值。
Stars: ✭ 145 (-88.33%)
Mutual labels:  metrics, performance, webperf
Sitespeed.io
Sitespeed.io is an open source tool that helps you monitor, analyze and optimize your website speed and performance, based on performance best practices advices from the coach and collecting browser metrics using the Navigation Timing API, User Timings and Visual Metrics (FirstVisualChange, SpeedIndex & LastVisualChange).
Stars: ✭ 4,255 (+242.32%)
Mutual labels:  metrics, webperf
Swagger Stats
API Observability. Trace API calls and Monitor API performance, health and usage statistics in Node.js Microservices.
Stars: ✭ 559 (-55.03%)
Mutual labels:  metrics, performance
Awesome Pagespeed Metrics
⚡Metrics to help understand page speed and user experience
Stars: ✭ 585 (-52.94%)
Mutual labels:  metrics, performance
React Native Performance
Monitor and measure React Native performance
Stars: ✭ 269 (-78.36%)
Mutual labels:  metrics, performance
Imageoptim Cli
Make optimisation of images part of your automated build process
Stars: ✭ 3,215 (+158.65%)
Mutual labels:  performance, webperf
Inspectit
inspectIT is the leading Open Source APM (Application Performance Management) tool for analyzing your Java (EE) applications.
Stars: ✭ 513 (-58.73%)
Mutual labels:  metrics, performance
Pcp
Performance Co-Pilot
Stars: ✭ 716 (-42.4%)
Mutual labels:  metrics, performance
Browser Perf
Performance Metrics for Web Browsers
Stars: ✭ 930 (-25.18%)
Mutual labels:  metrics, performance
Performance Bookmarklet
Performance-Bookmarklet helps to analyze the current page through the Resource Timing API, Navigation Timing API and User-Timing - requests by type, domain, load times, marks and more. Sort of a light live WebPageTest.
Stars: ✭ 997 (-19.79%)
Mutual labels:  performance, webperf
Sqip
"SQIP" (pronounced \skwɪb\ like the non-magical folk of magical descent) is a SVG-based LQIP technique.
Stars: ✭ 3,074 (+147.3%)
Mutual labels:  performance, webperf
Wallace Cli
Pretty CSS analytics on the CLI
Stars: ✭ 281 (-77.39%)
Mutual labels:  metrics, performance
App perf
Open source application performance monitoring tool with emphasis on ease of setup and use. Providing similar functionality like NewRelic/AppNeta/Skylight etc.
Stars: ✭ 353 (-71.6%)
Mutual labels:  metrics, performance
Webpack Lighthouse Plugin
A Webpack plugin for Lighthouse
Stars: ✭ 271 (-78.2%)
Mutual labels:  lighthouse, performance
Metered Rs
Fast, ergonomic metrics for Rust
Stars: ✭ 258 (-79.24%)
Mutual labels:  metrics, performance
Yall.js
A fast, flexible, and small SEO-friendly lazy loader.
Stars: ✭ 1,163 (-6.44%)
Mutual labels:  performance, webperf
lighthouse-mocha-example
Sample using lighthouse and lighthouse-core with Mocha to run tests on your project/site.
Stars: ✭ 60 (-95.17%)
Mutual labels:  webperf, lighthouse
webperf-dashboard
Web Performance Dashboard forked from https://github.com/boyney123/garie
Stars: ✭ 51 (-95.9%)
Mutual labels:  metrics, lighthouse
Analyze Css
CSS selectors complexity and performance analyzer
Stars: ✭ 657 (-47.14%)
Mutual labels:  metrics, webperf

Deprecated

In favour of better support and many cool features of:

  • Lighthouse CI - is a suite of tools that make continuously running, saving, retrieving, and asserting against Lighthouse results as easy as possible.
  • Lighthouse CI Action - action integrates Lighthouse CI with Github Actions environment. Making it simple to see failed tests, upload results, run jobs in parallel, store secrets, and interpolate env variables.
  • Treo.sh - Page speed monitoring made simple.

PWMetrics

Progressive web metrics at your fingertipz. 💅

CLI tool and lib to gather performance metrics via Lighthouse.

image

Documentation on these metrics in the works. If you hit bugs in the metrics collection, report at Lighthouse issues. How to use article

Install NPM pwmetrics package

$ yarn global add pwmetrics
# or
$ yarn add --dev pwmetrics

CLI Usage

$ pwmetrics <url> <flags>

pwmetrics http://example.com/

# --runs=n     Does n runs (eg. 3, 5), and reports the median run's numbers.
#              Median run selected by run with the median TTI.
pwmetrics http://example.com/ --runs=3

# --json       Reports json details to stdout.
pwmetrics http://example.com/ --json

# returns...
# {runs: [{
#   "timings": [
#     {
#       "name": "First Contentful Paint",
#       "value": 289.642
#     },
#     {
#       "name": "Largest Contentful Paint",
#       "value": 292
#     },
#     ...

# --output-path       File path to save results.
pwmetrics http://example.com/ --output-path='pathToFile/file.json'

# --config        Provide configuration (defaults to `package.json`). See _Defining config_ below.
pwmetrics --config=pwmetrics-config.js

# --submit       Submit results to Google Sheets. See _Defining submit_ below.
pwmetrics --submit

# --upload       Upload Lighthouse traces to Google Drive. See _Defining upload_ below.
pwmetrics --upload

# --view       View Lighthouse traces, which were uploaded to Google Drive, in DevTools. See _Defining view_ below.
pwmetrics --view

##
## CLI options useful for CI
##

# --expectations  Assert metrics results against provides values. See _Defining expectations_ below.
pwmetrics --expectations

# --fail-on-error  Exit PWMetrics with an error status code after the first unfilled expectation.
pwmetrics --fail-on-error


Defining config

# run pwmetrics with config in package.json
pwmetrics --config

package.json

...
  "pwmetrics": {
    "url": "http://example.com/",
    // other configuration options
  }
...
# run pwmetrics with config in pwmetrics-config.js
pwmetrics --config=pwmetrics-config.js

pwmetrics-config.js

module.exports = {
  url: 'http://example.com/',
   // other configuration options. Read _All available configuration options_
}

All available configuration options

pwmetrics-config.js

const METRICS = require('pwmetrics/lib/metrics');

module.exports = {
  url: 'http://example.com/',
  flags: { // AKA feature flags
    runs: 3, // number or runs
    submit: true, // turn on submitting to Google Sheets
    upload: true, // turn on uploading to Google Drive
    view: true, // open uploaded traces to Google Drive in DevTools
    expectations: true, // turn on assertion metrics results against provides values
    json: true, // not required, set to true if you want json output
    outputPath: 'stdout', // not required, only needed if you have specified json output, can be "stdout" or a path
    chromePath: '/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary', //optional path to specific Chrome location
    chromeFlags: '', // custom flags to pass to Chrome. For a full list of flags, see http://peter.sh/experiments/chromium-command-line-switches/.
    // Note: pwmetrics supports all flags from Lighthouse
    showOutput: true, // not required, set to false for pwmetrics not output any console.log messages
    failOnError: false // not required, set to true if you want to fail the process on expectations errors
  },
  expectations: {
    // these expectations values are examples, for your cases set your own
    // it's not required to use all metrics, you can use just a few of them
    // Read _Available metrics_ where all keys are defined
    [METRICS.TTFCP]: {
      warn: '>=1500',
      error: '>=2000'
    },
    [METRICS.TTLCP]: {
      warn: '>=2000',
      error: '>=3000'
    },
    [METRICS.TTI]: {
      ...
    },
    [METRICS.TBT]: {
      ...
    },
    [METRICS.SI]: {
      ...
    },
  },
  sheets: {
    type: 'GOOGLE_SHEETS', // sheets service type. Available types: GOOGLE_SHEETS
    options: {
      spreadsheetId: 'sheet_id',
      tableName: 'data',
      uploadMedian: false // not required, set to true if you want to upload only the median run
    }
  },
  clientSecret: {
    // Data object. Can be get
    // either
    // by (using everything in step 1 here)[https://developers.google.com/sheets/api/quickstart/nodejs#step_1_turn_on_the_api_name]
    //
    // example format:
    //
    // installed: {
    //   client_id: "sample_client_id",
    //   project_id: "sample_project_id",
    //   auth_uri: "https://accounts.google.com/o/oauth2/auth",
    //   token_uri: "https://accounts.google.com/o/oauth2/token",
    //   auth_provider_x509_cert_url: "https://www.googleapis.com/oauth2/v1/certs",
    //   client_secret: "sample_client_secret",
    //   redirect_uris: [
    //     "url",
    //     "http://localhost"
    //   ]
    // }
    //
    // or
    // by (using everything in step 1 here)[https://developers.google.com/drive/v3/web/quickstart/nodejs]
  }
}

Defining expectations

Recipes for using with CI

# run pwmetrics with config in package.json
pwmetrics --expectations

package.json

...
  "pwmetrics": {
    "url": "http://example.com/",
    "expectations": {
      ...
    }
  }
...
# run pwmetrics with config in pwmetrics-config.js
pwmetrics --expectations --config=pwmetrics-config.js

Defining submit

Submit results to Google Sheets

Instructions:

  • Copy this spreadsheet.
  • Copy the ID of the spreadsheet into the config as value of sheets.options.spreadsheetId property.
  • Setup Google Developer project and get credentials. (everything in step 1 here)
  • Take a client_secret and put it into the config as value of clientSecret property.
# run pwmetrics with config in package.json
pwmetrics --submit
# run pwmetrics with config in pwmetrics-config.js
pwmetrics --submit --config=pwmetrics-config.js

pwmetrics-config.js

module.exports = {
  'url': 'http://example.com/',
  'sheets': {
    ...
  },
  'clientSecret': {
    ...
  }
}

Defining upload

Upload Lighthouse traces to Google Drive

Instructions:

  • Setup Google Developer project and get credentials. (everything in step 1 here)
  • Take a client_secret and put it into the config as value of clientSecret property.
# run pwmetrics with config in package.json
pwmetrics --upload
# run pwmetrics with config in pwmetrics-config.js
pwmetrics --upload --config=pwmetrics-config.js

pwmetrics-config.js

module.exports = {
  'url': 'http://example.com/',
  'clientSecret': {
    ...
  }
}

View Lighthouse traces in timeline-viewer

Show Lighthouse traces in timeline-viewer.

Required to use upload flag

timeline-viewer - Shareable URLs for your Chrome DevTools Timeline traces.

# run pwmetrics with config in package.json
pwmetrics --upload --view
# run pwmetrics with config in your-own-file.js
pwmetrics --upload --view --config=your-own-file.js

pwmetrics-config.js

module.exports = {
  'url': 'http://example.com/',
  'clientSecret': {
    ...
  }
}

Available metrics:

All metrics now are stored in separate constant object located in pwmetrics/lib/metrics/metrics;

// lib/metrics/metrics.ts
{
  METRICS: {
    TTFCP: 'firstContentfulPaint',
    TTLCP: 'largestContentfulPaint',
    TBT: 'totalBlockingTime',
    TTI: 'interactive',
    SI: 'speedIndex'
  }
}

Read article Performance metrics. What’s this all about? which is decoding this metrics.

API

const PWMetrics = require('pwmetrics');

const options = {
  flags: {
    runs: 3, // number or runs
    submit: true, // turn on submitting to Google Sheets
    upload: true, // turn on uploading to Google Drive
    view: true, // open uploaded traces to Google Drive in DevTools
    expectations: true, // turn on assertation metrics results against provides values
    chromeFlags: '--headless' // run in headless Chrome
  }
};

const pwMetrics = new PWMetrics('http://example.com/', options); // _All available configuration options_ can be used as `options`
pwMetrics.start(); // returns Promise

Options

Option Type Default Description
flags* Object
{
  runs: 1,
  submit: false,
  upload: false,
  view: false,
  expectations: false,
  disableCpuThrottling: false,
  chromeFlags: ''
}
        
Feature flags
expectations Object {} See Defining expectations above.
sheets Object {} See Defining submit above.
clientSecret Object {} Client secrete data generated by Google API console. To setup Google Developer project and get credentials apply everything in step 1 here.

*pwmetrics supports all flags from Lighthouse. See here for the complete list.

Recipes

License

Apache 2.0. Google Inc.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].