How to use the lighthouse.Audit.computeLogNormalScore function in lighthouse

To help you get started, we’ve selected a few lighthouse 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 googleads / publisher-ads-lighthouse-plugin / lighthouse-plugin-publisher-ads / audits / tag-load-time.js View on Github external
static async audit(artifacts, context) {
    const trace = artifacts.traces[Audit.DEFAULT_PASS];
    const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
    const metricData = {trace, devtoolsLog, settings: context.settings};

    const {timing} = await ComputedTagLoadTime.request(metricData, context);
    if (!(timing > 0)) { // Handle NaN, etc.
      context.LighthouseRunWarnings.push(runWarning.NoTag);
      return auditNotApplicable.NoTag;
    }

    // NOTE: score is relative to page response time to avoid counting time for
    // first party rendering.
    return {
      numericValue: timing * 1e-3, // seconds
      score: Audit.computeLogNormalScore(
        timing,
        context.options.scorePODR,
        context.options.scoreMedian
      ),
      displayValue: str_(UIStrings.displayValue, {timeInMs: timing}),
    };
  }
}
github googleads / publisher-ads-lighthouse-plugin / lighthouse-plugin-publisher-ads / audits / bid-request-from-page-start.js View on Github external
static async audit(artifacts, context) {
    const trace = artifacts.traces[Audit.DEFAULT_PASS];
    const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
    const metricData = {trace, devtoolsLog, settings: context.settings};

    const {timing} = await ComputedBidRequestTime.request(metricData, context);
    if (!(timing > 0)) { // Handle NaN, etc.
      return auditNotApplicable.NoBids;
    }

    return {
      numericValue: timing * 1e-3,
      score: Audit.computeLogNormalScore(
        timing,
        context.options.scorePODR,
        context.options.scoreMedian
      ),
      displayValue: str_(UIStrings.displayValue, {timeInMs: timing}),
    };
  }
}
github googleads / publisher-ads-lighthouse-plugin / lighthouse-plugin-publisher-ads / audits / ad-request-from-page-start.js View on Github external
static async audit(artifacts, context) {
    const trace = artifacts.traces[Audit.DEFAULT_PASS];
    const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
    const metricData = {trace, devtoolsLog, settings: context.settings};

    const {timing} = await ComputedAdRequestTime.request(metricData, context);
    if (!(timing > 0)) { // Handle NaN, etc.
      context.LighthouseRunWarnings.push(runWarning.NoAds);
      return auditNotApplicable.NoAds;
    }

    return {
      numericValue: timing * 1e-3,
      score: Audit.computeLogNormalScore(
        timing,
        context.options.scorePODR,
        context.options.scoreMedian
      ),
      displayValue: str_(UIStrings.displayValue, {timeInMs: timing}),
    };
  }
}
github treosh / exthouse / src / utils / analysis.js View on Github external
function getExtensionExtraFiles(lhResult) {
  const headings = lhResult.audits['bootup-time'].details.headings
  const items = getExtensionFiles(lhResult)
  const numericValue = items.length
  const score = Audit.computeLogNormalScore(numericValue, 0.5, 2) // 0 is optiomal
  return {
    id: 'exthouse-extension-files',
    title: 'Extension files',
    description:
      'Extension files add extra CPU consumption for every URL visit. Bundle resources into one and leverage hot chaching. [Learn more](https://v8.dev/blog/code-caching-for-devs).',
    score,
    scoreDisplayMode: 'numeric',
    numericValue,
    displayValue: `${numericValue} file${numericValue !== 1 ? 's' : ''}`,
    details: Audit.makeTableDetails(headings, items)
  }
}
github googleads / publisher-ads-lighthouse-plugin / lighthouse-plugin-publisher-ads / audits / ad-request-from-tag-load.js View on Github external
await ComputedTagLoadTime.request(metricData, context);
    if (!(tagEndTime > 0)) { // Handle NaN, etc.
      return auditNotApplicable.NoTag;
    }

    const {timing: adStartTime} =
        await ComputedAdRequestTime.request(metricData, context);
    if (!(adStartTime > 0)) { // Handle NaN, etc.
      return auditNotApplicable.NoAds;
    }

    const adReqTimeMs = (adStartTime - tagEndTime);

    return {
      numericValue: adReqTimeMs * 1e-3,
      score: Audit.computeLogNormalScore(adReqTimeMs, PODR, MEDIAN),
      displayValue: str_(UIStrings.displayValue, {timeInMs: adReqTimeMs}),
    };
  }
}
github treosh / lighthouse-plugin-field-performance / src / utils / audit-helpers.js View on Github external
exports.createValueResult = (metricValue, timeUnit, options) => {
  let displayValue
  const numericValue = metricValue.percentile
  const score = Audit.computeLogNormalScore(numericValue, options.scorePODR, options.scoreMedian)

  if (isMs(timeUnit)) {
    displayValue = `${formatValue(numericValue, { isMs: true })} ms`
  } else {
    displayValue = `${formatValue(numericValue)} s`
  }

  return {
    score,
    numericValue,
    displayValue,
    details: createDistributionsTable(metricValue, timeUnit)
  }
}
github treosh / exthouse / src / utils / analysis.js View on Github external
function getMaxPotentialFidChange(lhResult, defaultDefails) {
  const maxFid = getMaxPotencialFid(lhResult)
  const numericValue = maxFid > defaultDefails.maxPotentcialFid ? maxFid - defaultDefails.maxPotentcialFid : 0
  const score = Audit.computeLogNormalScore(numericValue, 50, 250)
  return {
    id: 'exthouse-max-potential-fid-change',
    title: 'Max Potential First Input Delay change',
    description: `With an addition of extension Max FID changed from ${formatMsValue(
      defaultDefails.maxPotentcialFid
    )}ms to ${formatMsValue(
      maxFid
    )}ms. The change for the longest task duration highlights the impact on potential First Input Delay. [Learn more](https://developers.google.com/web/updates/2018/05/first-input-delay).`,
    score,
    scoreDisplayMode: 'numeric',
    numericValue,
    displayValue: `${formatMsValue(numericValue)} ms`
  }
}
github treosh / exthouse / src / utils / analysis.js View on Github external
function getNewLongTasks(lhResult, defaultDefails) {
  const longTasks = getLongTasks(lhResult)
  const files = getExtensionFiles(lhResult)
  const numericValue = files.length
    ? sum(longTasks.map(task => task.duration)) - sum(defaultDefails.longTasks.map(task => task.duration))
    : 0
  const score = Audit.computeLogNormalScore(numericValue, 50, 250)
  const headings = [
    { key: 'startTime', itemType: 'text', text: 'Start Time' },
    { key: 'duration', itemType: 'text', text: 'Duration' }
  ]
  const items = longTasks.map(task => ({
    startTime: `${formatMsValue(task.startTime)} ms`,
    duration: `${formatMsValue(task.duration)} ms`
  }))
  return {
    id: 'exthouse-new-long-tasks',
    title: 'Added Long Tasks',
    description: `The value represents a sum of [Long Tasks](https://developer.mozilla.org/en-US/docs/Web/API/Long_Tasks_API) added by extension. The table displays all long tasks occured.`,
    score,
    scoreDisplayMode: 'numeric',
    numericValue,
    displayValue: `${formatMsValue(numericValue)} ms`,