function findAuditDiffs(baseAudit, compareAudit, options = {}) {
  const auditId = baseAudit.id || '';
  const {percentAbsoluteDeltaThreshold = 0} = options;
  /** @type {Array<LHCI.AuditDiff>} */
  const diffs = [];

  if (auditsToNotDIff.includes(auditId)) return diffs;

  if (typeof baseAudit.score === 'number' || typeof compareAudit.score === 'number') {
    diffs.push(
      createAuditDiff({
        auditId,
        type: 'score',
        baseValue: normalizeScore(baseAudit),
        compareValue: normalizeScore(compareAudit),
      })
    );
  }

  if (
    typeof getNumericValue(baseAudit) === 'number' ||
    typeof getNumericValue(compareAudit) === 'number'
  ) {
    diffs.push(
      createAuditDiff({
        auditId,
        type: 'numericValue',
        baseValue: normalizeNumericValue(baseAudit),
        compareValue: normalizeNumericValue(compareAudit),
      })
    );
  }

  if (typeof baseAudit.displayValue === 'string' || typeof compareAudit.displayValue === 'string') {
    diffs.push({
      auditId,
      type: 'displayValue',
      baseValue: baseAudit.displayValue || '',
      compareValue: compareAudit.displayValue || '',
    });
  }

  let hasItemDetails = false;
  /** @type {Partial<LH.AuditResult['details']>} */
  const baseAuditDetails = baseAudit.details || {};
  /** @type {Partial<LH.AuditResult['details']>} */
  const compareAuditDetails = compareAudit.details || {};
  // TODO: support checklist.
  if (
    (baseAuditDetails.type !== 'debugdata' &&
      baseAuditDetails.type !== 'checklist' &&
      baseAuditDetails.items) ||
    (compareAuditDetails.type !== 'debugdata' &&
      compareAuditDetails.type !== 'checklist' &&
      compareAuditDetails.items)
  ) {
    hasItemDetails = true;
    const {items: baseItems, headings: baseHeadings} = normalizeDetails(baseAudit);
    const {items: compareItems, headings: compareHeadings} = normalizeDetails(compareAudit);
    const headings = baseHeadings.concat(compareHeadings);

    diffs.push(
      createAuditDiff({
        auditId,
        type: 'itemCount',
        baseValue: baseItems.length,
        compareValue: compareItems.length,
      })
    );

    diffs.push(...findAuditDetailItemsDiffs(auditId, baseItems, compareItems, headings));

    if (options.synthesizeItemKeyDiffs) {
      diffs.push(...synthesizeItemKeyDiffs(diffs, baseItems, compareItems));
    }
  }

  const filteredDiffs = diffs.filter(diff => {
    // Errors are always surfaced.
    if (diff.type === 'error') return true;
    // Additions and removals are always surfaced.
    if (diff.type === 'itemAddition' || diff.type === 'itemRemoval') return true;
    // If it's a score and we're not forcing all score diffs, only flag level changes.
    if (diff.type === 'score' && !options.forceAllScoreDiffs) {
      return getScoreLevel(diff.baseValue) !== getScoreLevel(diff.compareValue);
    }
    // If it's a display value change, ensure the values are different, and defer to the options.
    if (diff.type === 'displayValue') {
      return diff.baseValue !== diff.compareValue && !options.skipDisplayValueDiffs;
    }

    // Ensure the percent delta is above our threshold (0 by default).
    return getDeltaStats(diff).percentAbsoluteDelta > percentAbsoluteDeltaThreshold;
  });

  // If the only diff found was a displayValue diff, skip it as the others were probably ignored by
  // our percentAbsoluteDeltaThreshold.
  if (filteredDiffs.length === 1 && filteredDiffs[0].type === 'displayValue') return [];

  // If the only diff found was a numericValue/displayValue diff *AND* it seems like the result was flaky, skip it.
  // The result is likely flaky if the audit passed *OR* it was supposed to have details but no details items changed.
  const isAllPassing = compareAudit.score === 1 && baseAudit.score === 1;
  const group = getGroupForAuditId(auditId);
  if (
    group !== 'metrics' && // if metrics group audit is found, don't skip it
    filteredDiffs.every(diff => diff.type === 'displayValue' || diff.type === 'numericValue') &&
    (isAllPassing || hasItemDetails)
  ) {
    return [];
  }

  return filteredDiffs;
}
@param {LH.AuditResult} baseAudit
@param {LH.AuditResult} compareAudit
@param {{forceAllScoreDiffs?: boolean, skipDisplayValueDiffs?: boolean, synthesizeItemKeyDiffs?: boolean, percentAbsoluteDeltaThreshold?: number}} options
@return {Array<LHCI.AuditDiff>}