async function doTest(url, writeStream) {
  const results = await runLighthouse(url);
  const rawData = results.lhr;
  const userTimings = rawData.audits['user-timings']['details'];

  const logs = results.artifacts['devtoolsLogs']['defaultPass'];
  const harResult = await chromeHarCapturer.fromLog(url, logs);
  const harEntries = harResult['log']['entries'];

  let totaltransfersize = 0;
  let transfersizes = [];
  let times = [];
  for (entry in harEntries) {
    let time = 0;
    const request = harEntries[entry];
    const response = request['response'];
    const transfersize = response['_transferSize'];

    const timings = request['timings'];

    // add up all the timing components to get the request time
    for (key in request['timings']) {
      // null values are -1, we do not want those
      if (timings[key] >= 0) {
        time += timings[key];
      }
    }

    times.push(time);
    totaltransfersize += transfersize;
    transfersizes.push(transfersize);
  }

  const metrics = [
    rawData.audits['first-contentful-paint'].numericValue,
    rawData.audits['first-meaningful-paint'].numericValue,
    rawData.audits['speed-index'].numericValue,
    rawData.audits['total-blocking-time'].numericValue,
    rawData.audits['estimated-input-latency'].numericValue,
    rawData.audits['time-to-first-byte'].numericValue,
    rawData.audits['first-cpu-idle'].numericValue,
    rawData.audits['interactive'].numericValue,
    rawData.audits['network-rtt'].numericValue,
    rawData.audits['network-requests'].numericValue,
    rawData.audits['dom-size'].numericValue,
    totaltransfersize,
    avg(transfersizes),
    median(transfersizes),
    percentile(90, transfersizes),
    percentile(95, transfersizes),
    percentile(99, transfersizes),
    avg(times),
    median(times),
    percentile(90, times),
    percentile(95, times),
    percentile(99, times),
    times.length,
    getLowestTimeToWidget(userTimings),
    getMedianTimeToWidget(userTimings),
  ];

  let line = metrics.join(',');
  line += '\n';

  writeStream.write(line);
}
/**
 * Runs Google Lighthouse on the given url and writes metrics to the given
 * file stream
 *
 * @param url the url of the web page to test
 * @param writeStream file stream of the file to write to
 */
Runs Google Lighthouse on the given url and writes metrics to the given
file stream

@param url the url of the web page to test
@param writeStream file stream of the file to write to
Runs Google Lighthouse on the given url and writes metrics to the given file stream @param url the url of the web page to test @param writeStream file stream of the file to write to
async function doTest(url, writeStream) {
  const results = await runLighthouse(url);
  const rawData = results.lhr;
  const userTimings = rawData.audits['user-timings']['details'];
  const logs = results.artifacts['devtoolsLogs']['defaultPass'];
  const harResult = await chromeHarCapturer.fromLog(url, logs);
  const harEntries = harResult['log']['entries'];
  let totaltransfersize = 0;
  let transfersizes = [];
  let times = [];
  for (entry in harEntries) {
    let time = 0;
    const request = harEntries[entry];
    const response = request['response'];
    const transfersize = response['_transferSize'];
    const timings = request['timings'];
    for (key in request['timings']) {
      if (timings[key] >= 0) {
        time += timings[key];
      }
    }
    times.push(time);
    totaltransfersize += transfersize;
    transfersizes.push(transfersize);
  }
  const metrics = [
    rawData.audits['first-contentful-paint'].numericValue,
    rawData.audits['first-meaningful-paint'].numericValue,
    rawData.audits['speed-index'].numericValue,
    rawData.audits['total-blocking-time'].numericValue,
    rawData.audits['estimated-input-latency'].numericValue,
    rawData.audits['time-to-first-byte'].numericValue,
    rawData.audits['first-cpu-idle'].numericValue,
    rawData.audits['interactive'].numericValue,
    rawData.audits['network-rtt'].numericValue,
    rawData.audits['network-requests'].numericValue,
    rawData.audits['dom-size'].numericValue,
    totaltransfersize,
    avg(transfersizes),
    median(transfersizes),
    percentile(90, transfersizes),
    percentile(95, transfersizes),
    percentile(99, transfersizes),
    avg(times),
    median(times),
    percentile(90, times),
    percentile(95, times),
    percentile(99, times),
    times.length,
    getLowestTimeToWidget(userTimings),
    getMedianTimeToWidget(userTimings),
  ];
  let line = metrics.join(',');
  line += '\n';
  writeStream.write(line);
}
async function doTest ( url , writeStream ) { const results = await runLighthouse ( url ) ; const rawData = results . lhr ; const userTimings = rawData . audits [ 'user-timings' ] [ 'details' ] ; const logs = results . artifacts [ 'devtoolsLogs' ] [ 'defaultPass' ] ; const harResult = await chromeHarCapturer . fromLog ( url , logs ) ; const harEntries = harResult [ 'log' ] [ 'entries' ] ; let totaltransfersize = 0 ; let transfersizes = [ ] ; let times = [ ] ; for ( entry in harEntries ) { let time = 0 ; const request = harEntries [ entry ] ; const response = request [ 'response' ] ; const transfersize = response [ '_transferSize' ] ; const timings = request [ 'timings' ] ; for ( key in request [ 'timings' ] ) { if ( timings [ key ] >= 0 ) { time += timings [ key ] ; } } times . push ( time ) ; totaltransfersize += transfersize ; transfersizes . push ( transfersize ) ; } const metrics = [ rawData . audits [ 'first-contentful-paint' ] . numericValue , rawData . audits [ 'first-meaningful-paint' ] . numericValue , rawData . audits [ 'speed-index' ] . numericValue , rawData . audits [ 'total-blocking-time' ] . numericValue , rawData . audits [ 'estimated-input-latency' ] . numericValue , rawData . audits [ 'time-to-first-byte' ] . numericValue , rawData . audits [ 'first-cpu-idle' ] . numericValue , rawData . audits [ 'interactive' ] . numericValue , rawData . audits [ 'network-rtt' ] . numericValue , rawData . audits [ 'network-requests' ] . numericValue , rawData . audits [ 'dom-size' ] . numericValue , totaltransfersize , avg ( transfersizes ) , median ( transfersizes ) , percentile ( 90 , transfersizes ) , percentile ( 95 , transfersizes ) , percentile ( 99 , transfersizes ) , avg ( times ) , median ( times ) , percentile ( 90 , times ) , percentile ( 95 , times ) , percentile ( 99 , times ) , times . length , getLowestTimeToWidget ( userTimings ) , getMedianTimeToWidget ( userTimings ) , ] ; let line = metrics . join ( ',' ) ; line += '\n' ; writeStream . write ( line ) ; }
Runs Google Lighthouse on the given url and writes metrics to the given
 file stream
Runs Google Lighthouse on the given url and writes metrics to the given file stream
// add up all the timing components to get the request time // null values are -1, we do not want those