How to use webpagetest - 4 common examples

To help you get started, we’ve selected a few webpagetest examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sitespeedio / sitespeed.io / lib / plugins / webpagetest / analyzer.js View on Github external
data.data.median.firstView.chromeUserTiming.forEach(measure => {
          chromeUserTiming[measure.name] = measure.time;
        });
        data.data.median.firstView.chromeUserTiming = chromeUserTiming;
        log.verbose(
          'detected chromeUserTiming and restructured them to :%:2j',
          chromeUserTiming
        );
      }

      const promises = [];
      let har;
      promises.push(
        getHARData(id, {})
          .then(theHar => (har = theHar))
          .catch(WPTAPIError, error =>
            log.warn(
              `Couldn't get HAR for id ${id} ${error.message} (url = ${url})`
            )
          )
      );

      const traces = {};
      const views = ['firstView'];
      if (!wptOptions.firstViewOnly) {
        views.push('repeatView');
      }

      views.forEach(function(view) {
        for (let run = 1; run <= wptOptions.runs; run++) {
          // The WPT API wrapper mutates the options object, why ohh why?!?!?!
          const repeatView = view === 'repeatView';
github sitespeedio / sitespeed.io / lib / plugins / webpagetest / index.js View on Github external
];

function addCustomMetric(result, filterRegistry) {
  const customMetrics = get(result, 'data.median.firstView.custom');
  if (customMetrics) {
    for (const customMetric of customMetrics) {
      filterRegistry.addFilterForType(
        'data.median.*.' + customMetric,
        'webpagetest.pageSummary'
      );
    }
  }
}

const defaultConfig = {
  host: WebPageTest.defaultServer,
  location: 'Dulles:Chrome',
  connectivity: 'Cable',
  runs: 3,
  pollResults: 10,
  timeout: 600,
  includeRepeatView: false,
  private: true,
  aftRenderingTime: true,
  video: true,
  timeline: false
};

function isPublicWptHost(address) {
  const host = /^(https?:\/\/)?([^/]*)/i.exec(address);
  return host && host[2] === urlParser.parse(WebPageTest.defaultServer).host;
}
github sitespeedio / sitespeed.io / lib / plugins / webpagetest / index.js View on Github external
function isPublicWptHost(address) {
  const host = /^(https?:\/\/)?([^/]*)/i.exec(address);
  return host && host[2] === urlParser.parse(WebPageTest.defaultServer).host;
}
github sitespeedio / sitespeed.io / lib / plugins / webpagetest / analyzer.js View on Github external
promises.push(
            getWaterfallImage(id, {
              run,
              chartType: 'connection',
              repeatView
            })
              .then(img =>
                storageManager.writeDataForUrl(
                  img,
                  'wpt-waterfall-connection' + run + '-' + view + '.png',
                  url,
                  'waterfall'
                )
              )
              .catch(WPTAPIError, error =>
                log.warn(
                  `Couldn't get connection waterfall for id ${id}, run ${run}: ${
                    error.message
                  } (url = ${url})`
                )
              )
          );

          if (wptOptions.timeline) {
            promises.push(
              getChromeTraceData(id, {
                run,
                repeatView
              })
                .then(
                  trace => (traces['trace-' + run + '-wpt-' + view] = trace)

webpagetest

WebPageTest API wrapper for NodeJS

MIT
Latest version published 4 months ago

Package Health Score

68 / 100
Full package analysis