Best JavaScript code snippet using playwright-internal
ReactPerf.js
Source:ReactPerf.js  
...21// https://github.com/facebook/flow/pull/2353 for updates22function consoleTable(table) {23  console.table(table);24}25function warnInProduction() {26  if (alreadyWarned) {27    return;28  }29  alreadyWarned = true;30  if (typeof console !== 'undefined') {31    console.error('ReactPerf is not supported in the production builds of React. ' + 'To collect measurements, please use the development build of React instead.');32  }33}34function getLastMeasurements() {35  if (!(process.env.NODE_ENV !== 'production')) {36    warnInProduction();37    return [];38  }39  return ReactDebugTool.getFlushHistory();40}41function getExclusive() {42  var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();43  if (!(process.env.NODE_ENV !== 'production')) {44    warnInProduction();45    return [];46  }47  var aggregatedStats = {};48  var affectedIDs = {};49  function updateAggregatedStats(treeSnapshot, instanceID, timerType, applyUpdate) {50    var displayName = treeSnapshot[instanceID].displayName;51    var key = displayName;52    var stats = aggregatedStats[key];53    if (!stats) {54      affectedIDs[key] = {};55      stats = aggregatedStats[key] = {56        key: key,57        instanceCount: 0,58        counts: {},59        durations: {},60        totalDuration: 061      };62    }63    if (!stats.durations[timerType]) {64      stats.durations[timerType] = 0;65    }66    if (!stats.counts[timerType]) {67      stats.counts[timerType] = 0;68    }69    affectedIDs[key][instanceID] = true;70    applyUpdate(stats);71  }72  flushHistory.forEach(function (flush) {73    var measurements = flush.measurements,74        treeSnapshot = flush.treeSnapshot;75    measurements.forEach(function (measurement) {76      var duration = measurement.duration,77          instanceID = measurement.instanceID,78          timerType = measurement.timerType;79      updateAggregatedStats(treeSnapshot, instanceID, timerType, function (stats) {80        stats.totalDuration += duration;81        stats.durations[timerType] += duration;82        stats.counts[timerType]++;83      });84    });85  });86  return Object.keys(aggregatedStats).map(function (key) {87    return _extends({}, aggregatedStats[key], {88      instanceCount: Object.keys(affectedIDs[key]).length89    });90  }).sort(function (a, b) {91    return b.totalDuration - a.totalDuration;92  });93}94function getInclusive() {95  var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();96  if (!(process.env.NODE_ENV !== 'production')) {97    warnInProduction();98    return [];99  }100  var aggregatedStats = {};101  var affectedIDs = {};102  function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {103    var _treeSnapshot$instanc = treeSnapshot[instanceID],104        displayName = _treeSnapshot$instanc.displayName,105        ownerID = _treeSnapshot$instanc.ownerID;106    var owner = treeSnapshot[ownerID];107    var key = (owner ? owner.displayName + ' > ' : '') + displayName;108    var stats = aggregatedStats[key];109    if (!stats) {110      affectedIDs[key] = {};111      stats = aggregatedStats[key] = {112        key: key,113        instanceCount: 0,114        inclusiveRenderDuration: 0,115        renderCount: 0116      };117    }118    affectedIDs[key][instanceID] = true;119    applyUpdate(stats);120  }121  var isCompositeByID = {};122  flushHistory.forEach(function (flush) {123    var measurements = flush.measurements;124    measurements.forEach(function (measurement) {125      var instanceID = measurement.instanceID,126          timerType = measurement.timerType;127      if (timerType !== 'render') {128        return;129      }130      isCompositeByID[instanceID] = true;131    });132  });133  flushHistory.forEach(function (flush) {134    var measurements = flush.measurements,135        treeSnapshot = flush.treeSnapshot;136    measurements.forEach(function (measurement) {137      var duration = measurement.duration,138          instanceID = measurement.instanceID,139          timerType = measurement.timerType;140      if (timerType !== 'render') {141        return;142      }143      updateAggregatedStats(treeSnapshot, instanceID, function (stats) {144        stats.renderCount++;145      });146      var nextParentID = instanceID;147      while (nextParentID) {148        // As we traverse parents, only count inclusive time towards composites.149        // We know something is a composite if its render() was called.150        if (isCompositeByID[nextParentID]) {151          updateAggregatedStats(treeSnapshot, nextParentID, function (stats) {152            stats.inclusiveRenderDuration += duration;153          });154        }155        nextParentID = treeSnapshot[nextParentID].parentID;156      }157    });158  });159  return Object.keys(aggregatedStats).map(function (key) {160    return _extends({}, aggregatedStats[key], {161      instanceCount: Object.keys(affectedIDs[key]).length162    });163  }).sort(function (a, b) {164    return b.inclusiveRenderDuration - a.inclusiveRenderDuration;165  });166}167function getWasted() {168  var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();169  if (!(process.env.NODE_ENV !== 'production')) {170    warnInProduction();171    return [];172  }173  var aggregatedStats = {};174  var affectedIDs = {};175  function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {176    var _treeSnapshot$instanc2 = treeSnapshot[instanceID],177        displayName = _treeSnapshot$instanc2.displayName,178        ownerID = _treeSnapshot$instanc2.ownerID;179    var owner = treeSnapshot[ownerID];180    var key = (owner ? owner.displayName + ' > ' : '') + displayName;181    var stats = aggregatedStats[key];182    if (!stats) {183      affectedIDs[key] = {};184      stats = aggregatedStats[key] = {185        key: key,186        instanceCount: 0,187        inclusiveRenderDuration: 0,188        renderCount: 0189      };190    }191    affectedIDs[key][instanceID] = true;192    applyUpdate(stats);193  }194  flushHistory.forEach(function (flush) {195    var measurements = flush.measurements,196        treeSnapshot = flush.treeSnapshot,197        operations = flush.operations;198    var isDefinitelyNotWastedByID = {};199    // Find host components associated with an operation in this batch.200    // Mark all components in their parent tree as definitely not wasted.201    operations.forEach(function (operation) {202      var instanceID = operation.instanceID;203      var nextParentID = instanceID;204      while (nextParentID) {205        isDefinitelyNotWastedByID[nextParentID] = true;206        nextParentID = treeSnapshot[nextParentID].parentID;207      }208    });209    // Find composite components that rendered in this batch.210    // These are potential candidates for being wasted renders.211    var renderedCompositeIDs = {};212    measurements.forEach(function (measurement) {213      var instanceID = measurement.instanceID,214          timerType = measurement.timerType;215      if (timerType !== 'render') {216        return;217      }218      renderedCompositeIDs[instanceID] = true;219    });220    measurements.forEach(function (measurement) {221      var duration = measurement.duration,222          instanceID = measurement.instanceID,223          timerType = measurement.timerType;224      if (timerType !== 'render') {225        return;226      }227      // If there was a DOM update below this component, or it has just been228      // mounted, its render() is not considered wasted.229      var updateCount = treeSnapshot[instanceID].updateCount;230      if (isDefinitelyNotWastedByID[instanceID] || updateCount === 0) {231        return;232      }233      // We consider this render() wasted.234      updateAggregatedStats(treeSnapshot, instanceID, function (stats) {235        stats.renderCount++;236      });237      var nextParentID = instanceID;238      while (nextParentID) {239        // Any parents rendered during this batch are considered wasted240        // unless we previously marked them as dirty.241        var isWasted = renderedCompositeIDs[nextParentID] && !isDefinitelyNotWastedByID[nextParentID];242        if (isWasted) {243          updateAggregatedStats(treeSnapshot, nextParentID, function (stats) {244            stats.inclusiveRenderDuration += duration;245          });246        }247        nextParentID = treeSnapshot[nextParentID].parentID;248      }249    });250  });251  return Object.keys(aggregatedStats).map(function (key) {252    return _extends({}, aggregatedStats[key], {253      instanceCount: Object.keys(affectedIDs[key]).length254    });255  }).sort(function (a, b) {256    return b.inclusiveRenderDuration - a.inclusiveRenderDuration;257  });258}259function getOperations() {260  var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();261  if (!(process.env.NODE_ENV !== 'production')) {262    warnInProduction();263    return [];264  }265  var stats = [];266  flushHistory.forEach(function (flush, flushIndex) {267    var operations = flush.operations,268        treeSnapshot = flush.treeSnapshot;269    operations.forEach(function (operation) {270      var instanceID = operation.instanceID,271          type = operation.type,272          payload = operation.payload;273      var _treeSnapshot$instanc3 = treeSnapshot[instanceID],274          displayName = _treeSnapshot$instanc3.displayName,275          ownerID = _treeSnapshot$instanc3.ownerID;276      var owner = treeSnapshot[ownerID];277      var key = (owner ? owner.displayName + ' > ' : '') + displayName;278      stats.push({279        flushIndex: flushIndex,280        instanceID: instanceID,281        key: key,282        type: type,283        ownerID: ownerID,284        payload: payload285      });286    });287  });288  return stats;289}290function printExclusive(flushHistory) {291  if (!(process.env.NODE_ENV !== 'production')) {292    warnInProduction();293    return;294  }295  var stats = getExclusive(flushHistory);296  var table = stats.map(function (item) {297    var key = item.key,298        instanceCount = item.instanceCount,299        totalDuration = item.totalDuration;300    var renderCount = item.counts.render || 0;301    var renderDuration = item.durations.render || 0;302    return {303      Component: key,304      'Total time (ms)': roundFloat(totalDuration),305      'Instance count': instanceCount,306      'Total render time (ms)': roundFloat(renderDuration),307      'Average render time (ms)': renderCount ? roundFloat(renderDuration / renderCount) : undefined,308      'Render count': renderCount,309      'Total lifecycle time (ms)': roundFloat(totalDuration - renderDuration)310    };311  });312  consoleTable(table);313}314function printInclusive(flushHistory) {315  if (!(process.env.NODE_ENV !== 'production')) {316    warnInProduction();317    return;318  }319  var stats = getInclusive(flushHistory);320  var table = stats.map(function (item) {321    var key = item.key,322        instanceCount = item.instanceCount,323        inclusiveRenderDuration = item.inclusiveRenderDuration,324        renderCount = item.renderCount;325    return {326      'Owner > Component': key,327      'Inclusive render time (ms)': roundFloat(inclusiveRenderDuration),328      'Instance count': instanceCount,329      'Render count': renderCount330    };331  });332  consoleTable(table);333}334function printWasted(flushHistory) {335  if (!(process.env.NODE_ENV !== 'production')) {336    warnInProduction();337    return;338  }339  var stats = getWasted(flushHistory);340  var table = stats.map(function (item) {341    var key = item.key,342        instanceCount = item.instanceCount,343        inclusiveRenderDuration = item.inclusiveRenderDuration,344        renderCount = item.renderCount;345    return {346      'Owner > Component': key,347      'Inclusive wasted time (ms)': roundFloat(inclusiveRenderDuration),348      'Instance count': instanceCount,349      'Render count': renderCount350    };351  });352  consoleTable(table);353}354function printOperations(flushHistory) {355  if (!(process.env.NODE_ENV !== 'production')) {356    warnInProduction();357    return;358  }359  var stats = getOperations(flushHistory);360  var table = stats.map(function (stat) {361    return {362      'Owner > Node': stat.key,363      Operation: stat.type,364      Payload: typeof stat.payload === 'object' ? JSON.stringify(stat.payload) : stat.payload,365      'Flush index': stat.flushIndex,366      'Owner Component ID': stat.ownerID,367      'DOM Component ID': stat.instanceID368    };369  });370  consoleTable(table);371}372var warnedAboutPrintDOM = false;373function printDOM(measurements) {374  lowPriorityWarning(warnedAboutPrintDOM, '`ReactPerf.printDOM(...)` is deprecated. Use ' + '`ReactPerf.printOperations(...)` instead.');375  warnedAboutPrintDOM = true;376  return printOperations(measurements);377}378var warnedAboutGetMeasurementsSummaryMap = false;379function getMeasurementsSummaryMap(measurements) {380  lowPriorityWarning(warnedAboutGetMeasurementsSummaryMap, '`ReactPerf.getMeasurementsSummaryMap(...)` is deprecated. Use ' + '`ReactPerf.getWasted(...)` instead.');381  warnedAboutGetMeasurementsSummaryMap = true;382  return getWasted(measurements);383}384function start() {385  if (!(process.env.NODE_ENV !== 'production')) {386    warnInProduction();387    return;388  }389  ReactDebugTool.beginProfiling();390}391function stop() {392  if (!(process.env.NODE_ENV !== 'production')) {393    warnInProduction();394    return;395  }396  ReactDebugTool.endProfiling();397}398function isRunning() {399  if (!(process.env.NODE_ENV !== 'production')) {400    warnInProduction();401    return false;402  }403  return ReactDebugTool.isProfiling();404}405var ReactPerfAnalysis = {406  getLastMeasurements: getLastMeasurements,407  getExclusive: getExclusive,408  getInclusive: getInclusive,409  getWasted: getWasted,410  getOperations: getOperations,411  printExclusive: printExclusive,412  printInclusive: printInclusive,413  printWasted: printWasted,414  printOperations: printOperations,...f4a167ReactPerf.js
Source:f4a167ReactPerf.js  
...9}10function consoleTable(table) {11  console.table(table);12}13function warnInProduction() {14  if (alreadyWarned) {15    return;16  }17  alreadyWarned = true;18  if (typeof console !== 'undefined') {19    console.error('ReactPerf is not supported in the production builds of React. ' + 'To collect measurements, please use the development build of React instead.');20  }21}22function getLastMeasurements() {23  if (!__DEV__) {24    warnInProduction();25    return [];26  }27  return ReactDebugTool.getFlushHistory();28}29function getExclusive() {30  var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();31  if (!__DEV__) {32    warnInProduction();33    return [];34  }35  var aggregatedStats = {};36  var affectedIDs = {};37  function updateAggregatedStats(treeSnapshot, instanceID, timerType, applyUpdate) {38    var displayName = treeSnapshot[instanceID].displayName;39    var key = displayName;40    var stats = aggregatedStats[key];41    if (!stats) {42      affectedIDs[key] = {};43      stats = aggregatedStats[key] = {44        key: key,45        instanceCount: 0,46        counts: {},47        durations: {},48        totalDuration: 049      };50    }51    if (!stats.durations[timerType]) {52      stats.durations[timerType] = 0;53    }54    if (!stats.counts[timerType]) {55      stats.counts[timerType] = 0;56    }57    affectedIDs[key][instanceID] = true;58    applyUpdate(stats);59  }60  flushHistory.forEach(function (flush) {61    var measurements = flush.measurements,62        treeSnapshot = flush.treeSnapshot;63    measurements.forEach(function (measurement) {64      var duration = measurement.duration,65          instanceID = measurement.instanceID,66          timerType = measurement.timerType;67      updateAggregatedStats(treeSnapshot, instanceID, timerType, function (stats) {68        stats.totalDuration += duration;69        stats.durations[timerType] += duration;70        stats.counts[timerType]++;71      });72    });73  });74  return Object.keys(aggregatedStats).map(function (key) {75    return babelHelpers.extends({}, aggregatedStats[key], {76      instanceCount: Object.keys(affectedIDs[key]).length77    });78  }).sort(function (a, b) {79    return b.totalDuration - a.totalDuration;80  });81}82function getInclusive() {83  var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();84  if (!__DEV__) {85    warnInProduction();86    return [];87  }88  var aggregatedStats = {};89  var affectedIDs = {};90  function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {91    var _treeSnapshot$instanc = treeSnapshot[instanceID],92        displayName = _treeSnapshot$instanc.displayName,93        ownerID = _treeSnapshot$instanc.ownerID;94    var owner = treeSnapshot[ownerID];95    var key = (owner ? owner.displayName + ' > ' : '') + displayName;96    var stats = aggregatedStats[key];97    if (!stats) {98      affectedIDs[key] = {};99      stats = aggregatedStats[key] = {100        key: key,101        instanceCount: 0,102        inclusiveRenderDuration: 0,103        renderCount: 0104      };105    }106    affectedIDs[key][instanceID] = true;107    applyUpdate(stats);108  }109  var isCompositeByID = {};110  flushHistory.forEach(function (flush) {111    var measurements = flush.measurements;112    measurements.forEach(function (measurement) {113      var instanceID = measurement.instanceID,114          timerType = measurement.timerType;115      if (timerType !== 'render') {116        return;117      }118      isCompositeByID[instanceID] = true;119    });120  });121  flushHistory.forEach(function (flush) {122    var measurements = flush.measurements,123        treeSnapshot = flush.treeSnapshot;124    measurements.forEach(function (measurement) {125      var duration = measurement.duration,126          instanceID = measurement.instanceID,127          timerType = measurement.timerType;128      if (timerType !== 'render') {129        return;130      }131      updateAggregatedStats(treeSnapshot, instanceID, function (stats) {132        stats.renderCount++;133      });134      var nextParentID = instanceID;135      while (nextParentID) {136        if (isCompositeByID[nextParentID]) {137          updateAggregatedStats(treeSnapshot, nextParentID, function (stats) {138            stats.inclusiveRenderDuration += duration;139          });140        }141        nextParentID = treeSnapshot[nextParentID].parentID;142      }143    });144  });145  return Object.keys(aggregatedStats).map(function (key) {146    return babelHelpers.extends({}, aggregatedStats[key], {147      instanceCount: Object.keys(affectedIDs[key]).length148    });149  }).sort(function (a, b) {150    return b.inclusiveRenderDuration - a.inclusiveRenderDuration;151  });152}153function getWasted() {154  var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();155  if (!__DEV__) {156    warnInProduction();157    return [];158  }159  var aggregatedStats = {};160  var affectedIDs = {};161  function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {162    var _treeSnapshot$instanc2 = treeSnapshot[instanceID],163        displayName = _treeSnapshot$instanc2.displayName,164        ownerID = _treeSnapshot$instanc2.ownerID;165    var owner = treeSnapshot[ownerID];166    var key = (owner ? owner.displayName + ' > ' : '') + displayName;167    var stats = aggregatedStats[key];168    if (!stats) {169      affectedIDs[key] = {};170      stats = aggregatedStats[key] = {171        key: key,172        instanceCount: 0,173        inclusiveRenderDuration: 0,174        renderCount: 0175      };176    }177    affectedIDs[key][instanceID] = true;178    applyUpdate(stats);179  }180  flushHistory.forEach(function (flush) {181    var measurements = flush.measurements,182        treeSnapshot = flush.treeSnapshot,183        operations = flush.operations;184    var isDefinitelyNotWastedByID = {};185    operations.forEach(function (operation) {186      var instanceID = operation.instanceID;187      var nextParentID = instanceID;188      while (nextParentID) {189        isDefinitelyNotWastedByID[nextParentID] = true;190        nextParentID = treeSnapshot[nextParentID].parentID;191      }192    });193    var renderedCompositeIDs = {};194    measurements.forEach(function (measurement) {195      var instanceID = measurement.instanceID,196          timerType = measurement.timerType;197      if (timerType !== 'render') {198        return;199      }200      renderedCompositeIDs[instanceID] = true;201    });202    measurements.forEach(function (measurement) {203      var duration = measurement.duration,204          instanceID = measurement.instanceID,205          timerType = measurement.timerType;206      if (timerType !== 'render') {207        return;208      }209      var updateCount = treeSnapshot[instanceID].updateCount;210      if (isDefinitelyNotWastedByID[instanceID] || updateCount === 0) {211        return;212      }213      updateAggregatedStats(treeSnapshot, instanceID, function (stats) {214        stats.renderCount++;215      });216      var nextParentID = instanceID;217      while (nextParentID) {218        var isWasted = renderedCompositeIDs[nextParentID] && !isDefinitelyNotWastedByID[nextParentID];219        if (isWasted) {220          updateAggregatedStats(treeSnapshot, nextParentID, function (stats) {221            stats.inclusiveRenderDuration += duration;222          });223        }224        nextParentID = treeSnapshot[nextParentID].parentID;225      }226    });227  });228  return Object.keys(aggregatedStats).map(function (key) {229    return babelHelpers.extends({}, aggregatedStats[key], {230      instanceCount: Object.keys(affectedIDs[key]).length231    });232  }).sort(function (a, b) {233    return b.inclusiveRenderDuration - a.inclusiveRenderDuration;234  });235}236function getOperations() {237  var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();238  if (!__DEV__) {239    warnInProduction();240    return [];241  }242  var stats = [];243  flushHistory.forEach(function (flush, flushIndex) {244    var operations = flush.operations,245        treeSnapshot = flush.treeSnapshot;246    operations.forEach(function (operation) {247      var instanceID = operation.instanceID,248          type = operation.type,249          payload = operation.payload;250      var _treeSnapshot$instanc3 = treeSnapshot[instanceID],251          displayName = _treeSnapshot$instanc3.displayName,252          ownerID = _treeSnapshot$instanc3.ownerID;253      var owner = treeSnapshot[ownerID];254      var key = (owner ? owner.displayName + ' > ' : '') + displayName;255      stats.push({256        flushIndex: flushIndex,257        instanceID: instanceID,258        key: key,259        type: type,260        ownerID: ownerID,261        payload: payload262      });263    });264  });265  return stats;266}267function printExclusive(flushHistory) {268  if (!__DEV__) {269    warnInProduction();270    return;271  }272  var stats = getExclusive(flushHistory);273  var table = stats.map(function (item) {274    var key = item.key,275        instanceCount = item.instanceCount,276        totalDuration = item.totalDuration;277    var renderCount = item.counts.render || 0;278    var renderDuration = item.durations.render || 0;279    return {280      'Component': key,281      'Total time (ms)': roundFloat(totalDuration),282      'Instance count': instanceCount,283      'Total render time (ms)': roundFloat(renderDuration),284      'Average render time (ms)': renderCount ? roundFloat(renderDuration / renderCount) : undefined,285      'Render count': renderCount,286      'Total lifecycle time (ms)': roundFloat(totalDuration - renderDuration)287    };288  });289  consoleTable(table);290}291function printInclusive(flushHistory) {292  if (!__DEV__) {293    warnInProduction();294    return;295  }296  var stats = getInclusive(flushHistory);297  var table = stats.map(function (item) {298    var key = item.key,299        instanceCount = item.instanceCount,300        inclusiveRenderDuration = item.inclusiveRenderDuration,301        renderCount = item.renderCount;302    return {303      'Owner > Component': key,304      'Inclusive render time (ms)': roundFloat(inclusiveRenderDuration),305      'Instance count': instanceCount,306      'Render count': renderCount307    };308  });309  consoleTable(table);310}311function printWasted(flushHistory) {312  if (!__DEV__) {313    warnInProduction();314    return;315  }316  var stats = getWasted(flushHistory);317  var table = stats.map(function (item) {318    var key = item.key,319        instanceCount = item.instanceCount,320        inclusiveRenderDuration = item.inclusiveRenderDuration,321        renderCount = item.renderCount;322    return {323      'Owner > Component': key,324      'Inclusive wasted time (ms)': roundFloat(inclusiveRenderDuration),325      'Instance count': instanceCount,326      'Render count': renderCount327    };328  });329  consoleTable(table);330}331function printOperations(flushHistory) {332  if (!__DEV__) {333    warnInProduction();334    return;335  }336  var stats = getOperations(flushHistory);337  var table = stats.map(function (stat) {338    return {339      'Owner > Node': stat.key,340      'Operation': stat.type,341      'Payload': typeof stat.payload === 'object' ? JSON.stringify(stat.payload) : stat.payload,342      'Flush index': stat.flushIndex,343      'Owner Component ID': stat.ownerID,344      'DOM Component ID': stat.instanceID345    };346  });347  consoleTable(table);348}349var warnedAboutPrintDOM = false;350function printDOM(measurements) {351  warning(warnedAboutPrintDOM, '`ReactPerf.printDOM(...)` is deprecated. Use ' + '`ReactPerf.printOperations(...)` instead.');352  warnedAboutPrintDOM = true;353  return printOperations(measurements);354}355var warnedAboutGetMeasurementsSummaryMap = false;356function getMeasurementsSummaryMap(measurements) {357  warning(warnedAboutGetMeasurementsSummaryMap, '`ReactPerf.getMeasurementsSummaryMap(...)` is deprecated. Use ' + '`ReactPerf.getWasted(...)` instead.');358  warnedAboutGetMeasurementsSummaryMap = true;359  return getWasted(measurements);360}361function start() {362  if (!__DEV__) {363    warnInProduction();364    return;365  }366  ReactDebugTool.beginProfiling();367}368function stop() {369  if (!__DEV__) {370    warnInProduction();371    return;372  }373  ReactDebugTool.endProfiling();374}375function isRunning() {376  if (!__DEV__) {377    warnInProduction();378    return false;379  }380  return ReactDebugTool.isProfiling();381}382var ReactPerfAnalysis = {383  getLastMeasurements: getLastMeasurements,384  getExclusive: getExclusive,385  getInclusive: getInclusive,386  getWasted: getWasted,387  getOperations: getOperations,388  printExclusive: printExclusive,389  printInclusive: printInclusive,390  printWasted: printWasted,391  printOperations: printOperations,...1e0976ReactPerf.js
Source:1e0976ReactPerf.js  
...9}10function consoleTable(table) {11  console.table(table);12}13function warnInProduction() {14  if (alreadyWarned) {15    return;16  }17  alreadyWarned = true;18  if (typeof console !== 'undefined') {19    console.error('ReactPerf is not supported in the production builds of React. ' + 'To collect measurements, please use the development build of React instead.');20  }21}22function getLastMeasurements() {23  if (!__DEV__) {24    warnInProduction();25    return [];26  }27  return ReactDebugTool.getFlushHistory();28}29function getExclusive() {30  var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();31  if (!__DEV__) {32    warnInProduction();33    return [];34  }35  var aggregatedStats = {};36  var affectedIDs = {};37  function updateAggregatedStats(treeSnapshot, instanceID, timerType, applyUpdate) {38    var displayName = treeSnapshot[instanceID].displayName;39    var key = displayName;40    var stats = aggregatedStats[key];41    if (!stats) {42      affectedIDs[key] = {};43      stats = aggregatedStats[key] = {44        key: key,45        instanceCount: 0,46        counts: {},47        durations: {},48        totalDuration: 049      };50    }51    if (!stats.durations[timerType]) {52      stats.durations[timerType] = 0;53    }54    if (!stats.counts[timerType]) {55      stats.counts[timerType] = 0;56    }57    affectedIDs[key][instanceID] = true;58    applyUpdate(stats);59  }60  flushHistory.forEach(function (flush) {61    var measurements = flush.measurements,62        treeSnapshot = flush.treeSnapshot;63    measurements.forEach(function (measurement) {64      var duration = measurement.duration,65          instanceID = measurement.instanceID,66          timerType = measurement.timerType;67      updateAggregatedStats(treeSnapshot, instanceID, timerType, function (stats) {68        stats.totalDuration += duration;69        stats.durations[timerType] += duration;70        stats.counts[timerType]++;71      });72    });73  });74  return Object.keys(aggregatedStats).map(function (key) {75    return babelHelpers.extends({}, aggregatedStats[key], {76      instanceCount: Object.keys(affectedIDs[key]).length77    });78  }).sort(function (a, b) {79    return b.totalDuration - a.totalDuration;80  });81}82function getInclusive() {83  var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();84  if (!__DEV__) {85    warnInProduction();86    return [];87  }88  var aggregatedStats = {};89  var affectedIDs = {};90  function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {91    var _treeSnapshot$instanc = treeSnapshot[instanceID],92        displayName = _treeSnapshot$instanc.displayName,93        ownerID = _treeSnapshot$instanc.ownerID;94    var owner = treeSnapshot[ownerID];95    var key = (owner ? owner.displayName + ' > ' : '') + displayName;96    var stats = aggregatedStats[key];97    if (!stats) {98      affectedIDs[key] = {};99      stats = aggregatedStats[key] = {100        key: key,101        instanceCount: 0,102        inclusiveRenderDuration: 0,103        renderCount: 0104      };105    }106    affectedIDs[key][instanceID] = true;107    applyUpdate(stats);108  }109  var isCompositeByID = {};110  flushHistory.forEach(function (flush) {111    var measurements = flush.measurements;112    measurements.forEach(function (measurement) {113      var instanceID = measurement.instanceID,114          timerType = measurement.timerType;115      if (timerType !== 'render') {116        return;117      }118      isCompositeByID[instanceID] = true;119    });120  });121  flushHistory.forEach(function (flush) {122    var measurements = flush.measurements,123        treeSnapshot = flush.treeSnapshot;124    measurements.forEach(function (measurement) {125      var duration = measurement.duration,126          instanceID = measurement.instanceID,127          timerType = measurement.timerType;128      if (timerType !== 'render') {129        return;130      }131      updateAggregatedStats(treeSnapshot, instanceID, function (stats) {132        stats.renderCount++;133      });134      var nextParentID = instanceID;135      while (nextParentID) {136        if (isCompositeByID[nextParentID]) {137          updateAggregatedStats(treeSnapshot, nextParentID, function (stats) {138            stats.inclusiveRenderDuration += duration;139          });140        }141        nextParentID = treeSnapshot[nextParentID].parentID;142      }143    });144  });145  return Object.keys(aggregatedStats).map(function (key) {146    return babelHelpers.extends({}, aggregatedStats[key], {147      instanceCount: Object.keys(affectedIDs[key]).length148    });149  }).sort(function (a, b) {150    return b.inclusiveRenderDuration - a.inclusiveRenderDuration;151  });152}153function getWasted() {154  var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();155  if (!__DEV__) {156    warnInProduction();157    return [];158  }159  var aggregatedStats = {};160  var affectedIDs = {};161  function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {162    var _treeSnapshot$instanc2 = treeSnapshot[instanceID],163        displayName = _treeSnapshot$instanc2.displayName,164        ownerID = _treeSnapshot$instanc2.ownerID;165    var owner = treeSnapshot[ownerID];166    var key = (owner ? owner.displayName + ' > ' : '') + displayName;167    var stats = aggregatedStats[key];168    if (!stats) {169      affectedIDs[key] = {};170      stats = aggregatedStats[key] = {171        key: key,172        instanceCount: 0,173        inclusiveRenderDuration: 0,174        renderCount: 0175      };176    }177    affectedIDs[key][instanceID] = true;178    applyUpdate(stats);179  }180  flushHistory.forEach(function (flush) {181    var measurements = flush.measurements,182        treeSnapshot = flush.treeSnapshot,183        operations = flush.operations;184    var isDefinitelyNotWastedByID = {};185    operations.forEach(function (operation) {186      var instanceID = operation.instanceID;187      var nextParentID = instanceID;188      while (nextParentID) {189        isDefinitelyNotWastedByID[nextParentID] = true;190        nextParentID = treeSnapshot[nextParentID].parentID;191      }192    });193    var renderedCompositeIDs = {};194    measurements.forEach(function (measurement) {195      var instanceID = measurement.instanceID,196          timerType = measurement.timerType;197      if (timerType !== 'render') {198        return;199      }200      renderedCompositeIDs[instanceID] = true;201    });202    measurements.forEach(function (measurement) {203      var duration = measurement.duration,204          instanceID = measurement.instanceID,205          timerType = measurement.timerType;206      if (timerType !== 'render') {207        return;208      }209      var updateCount = treeSnapshot[instanceID].updateCount;210      if (isDefinitelyNotWastedByID[instanceID] || updateCount === 0) {211        return;212      }213      updateAggregatedStats(treeSnapshot, instanceID, function (stats) {214        stats.renderCount++;215      });216      var nextParentID = instanceID;217      while (nextParentID) {218        var isWasted = renderedCompositeIDs[nextParentID] && !isDefinitelyNotWastedByID[nextParentID];219        if (isWasted) {220          updateAggregatedStats(treeSnapshot, nextParentID, function (stats) {221            stats.inclusiveRenderDuration += duration;222          });223        }224        nextParentID = treeSnapshot[nextParentID].parentID;225      }226    });227  });228  return Object.keys(aggregatedStats).map(function (key) {229    return babelHelpers.extends({}, aggregatedStats[key], {230      instanceCount: Object.keys(affectedIDs[key]).length231    });232  }).sort(function (a, b) {233    return b.inclusiveRenderDuration - a.inclusiveRenderDuration;234  });235}236function getOperations() {237  var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();238  if (!__DEV__) {239    warnInProduction();240    return [];241  }242  var stats = [];243  flushHistory.forEach(function (flush, flushIndex) {244    var operations = flush.operations,245        treeSnapshot = flush.treeSnapshot;246    operations.forEach(function (operation) {247      var instanceID = operation.instanceID,248          type = operation.type,249          payload = operation.payload;250      var _treeSnapshot$instanc3 = treeSnapshot[instanceID],251          displayName = _treeSnapshot$instanc3.displayName,252          ownerID = _treeSnapshot$instanc3.ownerID;253      var owner = treeSnapshot[ownerID];254      var key = (owner ? owner.displayName + ' > ' : '') + displayName;255      stats.push({256        flushIndex: flushIndex,257        instanceID: instanceID,258        key: key,259        type: type,260        ownerID: ownerID,261        payload: payload262      });263    });264  });265  return stats;266}267function printExclusive(flushHistory) {268  if (!__DEV__) {269    warnInProduction();270    return;271  }272  var stats = getExclusive(flushHistory);273  var table = stats.map(function (item) {274    var key = item.key,275        instanceCount = item.instanceCount,276        totalDuration = item.totalDuration;277    var renderCount = item.counts.render || 0;278    var renderDuration = item.durations.render || 0;279    return {280      'Component': key,281      'Total time (ms)': roundFloat(totalDuration),282      'Instance count': instanceCount,283      'Total render time (ms)': roundFloat(renderDuration),284      'Average render time (ms)': renderCount ? roundFloat(renderDuration / renderCount) : undefined,285      'Render count': renderCount,286      'Total lifecycle time (ms)': roundFloat(totalDuration - renderDuration)287    };288  });289  consoleTable(table);290}291function printInclusive(flushHistory) {292  if (!__DEV__) {293    warnInProduction();294    return;295  }296  var stats = getInclusive(flushHistory);297  var table = stats.map(function (item) {298    var key = item.key,299        instanceCount = item.instanceCount,300        inclusiveRenderDuration = item.inclusiveRenderDuration,301        renderCount = item.renderCount;302    return {303      'Owner > Component': key,304      'Inclusive render time (ms)': roundFloat(inclusiveRenderDuration),305      'Instance count': instanceCount,306      'Render count': renderCount307    };308  });309  consoleTable(table);310}311function printWasted(flushHistory) {312  if (!__DEV__) {313    warnInProduction();314    return;315  }316  var stats = getWasted(flushHistory);317  var table = stats.map(function (item) {318    var key = item.key,319        instanceCount = item.instanceCount,320        inclusiveRenderDuration = item.inclusiveRenderDuration,321        renderCount = item.renderCount;322    return {323      'Owner > Component': key,324      'Inclusive wasted time (ms)': roundFloat(inclusiveRenderDuration),325      'Instance count': instanceCount,326      'Render count': renderCount327    };328  });329  consoleTable(table);330}331function printOperations(flushHistory) {332  if (!__DEV__) {333    warnInProduction();334    return;335  }336  var stats = getOperations(flushHistory);337  var table = stats.map(function (stat) {338    return {339      'Owner > Node': stat.key,340      'Operation': stat.type,341      'Payload': typeof stat.payload === 'object' ? JSON.stringify(stat.payload) : stat.payload,342      'Flush index': stat.flushIndex,343      'Owner Component ID': stat.ownerID,344      'DOM Component ID': stat.instanceID345    };346  });347  consoleTable(table);348}349var warnedAboutPrintDOM = false;350function printDOM(measurements) {351  warning(warnedAboutPrintDOM, '`ReactPerf.printDOM(...)` is deprecated. Use ' + '`ReactPerf.printOperations(...)` instead.');352  warnedAboutPrintDOM = true;353  return printOperations(measurements);354}355var warnedAboutGetMeasurementsSummaryMap = false;356function getMeasurementsSummaryMap(measurements) {357  warning(warnedAboutGetMeasurementsSummaryMap, '`ReactPerf.getMeasurementsSummaryMap(...)` is deprecated. Use ' + '`ReactPerf.getWasted(...)` instead.');358  warnedAboutGetMeasurementsSummaryMap = true;359  return getWasted(measurements);360}361function start() {362  if (!__DEV__) {363    warnInProduction();364    return;365  }366  ReactDebugTool.beginProfiling();367}368function stop() {369  if (!__DEV__) {370    warnInProduction();371    return;372  }373  ReactDebugTool.endProfiling();374}375function isRunning() {376  if (!__DEV__) {377    warnInProduction();378    return false;379  }380  return ReactDebugTool.isProfiling();381}382var ReactPerfAnalysis = {383  getLastMeasurements: getLastMeasurements,384  getExclusive: getExclusive,385  getInclusive: getInclusive,386  getWasted: getWasted,387  getOperations: getOperations,388  printExclusive: printExclusive,389  printInclusive: printInclusive,390  printWasted: printWasted,391  printOperations: printOperations,...16edb4adaa753cbcca816d5dd5f0bc041a1046ReactPerf.js
Source:16edb4adaa753cbcca816d5dd5f0bc041a1046ReactPerf.js  
...9}10function consoleTable(table) {11  console.table(table);12}13function warnInProduction() {14  if (alreadyWarned) {15    return;16  }17  alreadyWarned = true;18  if (typeof console !== 'undefined') {19    console.error('ReactPerf is not supported in the production builds of React. ' + 'To collect measurements, please use the development build of React instead.');20  }21}22function getLastMeasurements() {23  if (!__DEV__) {24    warnInProduction();25    return [];26  }27  return ReactDebugTool.getFlushHistory();28}29function getExclusive() {30  var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();31  if (!__DEV__) {32    warnInProduction();33    return [];34  }35  var aggregatedStats = {};36  var affectedIDs = {};37  function updateAggregatedStats(treeSnapshot, instanceID, timerType, applyUpdate) {38    var displayName = treeSnapshot[instanceID].displayName;39    var key = displayName;40    var stats = aggregatedStats[key];41    if (!stats) {42      affectedIDs[key] = {};43      stats = aggregatedStats[key] = {44        key: key,45        instanceCount: 0,46        counts: {},47        durations: {},48        totalDuration: 049      };50    }51    if (!stats.durations[timerType]) {52      stats.durations[timerType] = 0;53    }54    if (!stats.counts[timerType]) {55      stats.counts[timerType] = 0;56    }57    affectedIDs[key][instanceID] = true;58    applyUpdate(stats);59  }60  flushHistory.forEach(function (flush) {61    var measurements = flush.measurements,62        treeSnapshot = flush.treeSnapshot;63    measurements.forEach(function (measurement) {64      var duration = measurement.duration,65          instanceID = measurement.instanceID,66          timerType = measurement.timerType;67      updateAggregatedStats(treeSnapshot, instanceID, timerType, function (stats) {68        stats.totalDuration += duration;69        stats.durations[timerType] += duration;70        stats.counts[timerType]++;71      });72    });73  });74  return Object.keys(aggregatedStats).map(function (key) {75    return babelHelpers.extends({}, aggregatedStats[key], {76      instanceCount: Object.keys(affectedIDs[key]).length77    });78  }).sort(function (a, b) {79    return b.totalDuration - a.totalDuration;80  });81}82function getInclusive() {83  var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();84  if (!__DEV__) {85    warnInProduction();86    return [];87  }88  var aggregatedStats = {};89  var affectedIDs = {};90  function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {91    var _treeSnapshot$instanc = treeSnapshot[instanceID],92        displayName = _treeSnapshot$instanc.displayName,93        ownerID = _treeSnapshot$instanc.ownerID;94    var owner = treeSnapshot[ownerID];95    var key = (owner ? owner.displayName + ' > ' : '') + displayName;96    var stats = aggregatedStats[key];97    if (!stats) {98      affectedIDs[key] = {};99      stats = aggregatedStats[key] = {100        key: key,101        instanceCount: 0,102        inclusiveRenderDuration: 0,103        renderCount: 0104      };105    }106    affectedIDs[key][instanceID] = true;107    applyUpdate(stats);108  }109  var isCompositeByID = {};110  flushHistory.forEach(function (flush) {111    var measurements = flush.measurements;112    measurements.forEach(function (measurement) {113      var instanceID = measurement.instanceID,114          timerType = measurement.timerType;115      if (timerType !== 'render') {116        return;117      }118      isCompositeByID[instanceID] = true;119    });120  });121  flushHistory.forEach(function (flush) {122    var measurements = flush.measurements,123        treeSnapshot = flush.treeSnapshot;124    measurements.forEach(function (measurement) {125      var duration = measurement.duration,126          instanceID = measurement.instanceID,127          timerType = measurement.timerType;128      if (timerType !== 'render') {129        return;130      }131      updateAggregatedStats(treeSnapshot, instanceID, function (stats) {132        stats.renderCount++;133      });134      var nextParentID = instanceID;135      while (nextParentID) {136        if (isCompositeByID[nextParentID]) {137          updateAggregatedStats(treeSnapshot, nextParentID, function (stats) {138            stats.inclusiveRenderDuration += duration;139          });140        }141        nextParentID = treeSnapshot[nextParentID].parentID;142      }143    });144  });145  return Object.keys(aggregatedStats).map(function (key) {146    return babelHelpers.extends({}, aggregatedStats[key], {147      instanceCount: Object.keys(affectedIDs[key]).length148    });149  }).sort(function (a, b) {150    return b.inclusiveRenderDuration - a.inclusiveRenderDuration;151  });152}153function getWasted() {154  var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();155  if (!__DEV__) {156    warnInProduction();157    return [];158  }159  var aggregatedStats = {};160  var affectedIDs = {};161  function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {162    var _treeSnapshot$instanc2 = treeSnapshot[instanceID],163        displayName = _treeSnapshot$instanc2.displayName,164        ownerID = _treeSnapshot$instanc2.ownerID;165    var owner = treeSnapshot[ownerID];166    var key = (owner ? owner.displayName + ' > ' : '') + displayName;167    var stats = aggregatedStats[key];168    if (!stats) {169      affectedIDs[key] = {};170      stats = aggregatedStats[key] = {171        key: key,172        instanceCount: 0,173        inclusiveRenderDuration: 0,174        renderCount: 0175      };176    }177    affectedIDs[key][instanceID] = true;178    applyUpdate(stats);179  }180  flushHistory.forEach(function (flush) {181    var measurements = flush.measurements,182        treeSnapshot = flush.treeSnapshot,183        operations = flush.operations;184    var isDefinitelyNotWastedByID = {};185    operations.forEach(function (operation) {186      var instanceID = operation.instanceID;187      var nextParentID = instanceID;188      while (nextParentID) {189        isDefinitelyNotWastedByID[nextParentID] = true;190        nextParentID = treeSnapshot[nextParentID].parentID;191      }192    });193    var renderedCompositeIDs = {};194    measurements.forEach(function (measurement) {195      var instanceID = measurement.instanceID,196          timerType = measurement.timerType;197      if (timerType !== 'render') {198        return;199      }200      renderedCompositeIDs[instanceID] = true;201    });202    measurements.forEach(function (measurement) {203      var duration = measurement.duration,204          instanceID = measurement.instanceID,205          timerType = measurement.timerType;206      if (timerType !== 'render') {207        return;208      }209      var updateCount = treeSnapshot[instanceID].updateCount;210      if (isDefinitelyNotWastedByID[instanceID] || updateCount === 0) {211        return;212      }213      updateAggregatedStats(treeSnapshot, instanceID, function (stats) {214        stats.renderCount++;215      });216      var nextParentID = instanceID;217      while (nextParentID) {218        var isWasted = renderedCompositeIDs[nextParentID] && !isDefinitelyNotWastedByID[nextParentID];219        if (isWasted) {220          updateAggregatedStats(treeSnapshot, nextParentID, function (stats) {221            stats.inclusiveRenderDuration += duration;222          });223        }224        nextParentID = treeSnapshot[nextParentID].parentID;225      }226    });227  });228  return Object.keys(aggregatedStats).map(function (key) {229    return babelHelpers.extends({}, aggregatedStats[key], {230      instanceCount: Object.keys(affectedIDs[key]).length231    });232  }).sort(function (a, b) {233    return b.inclusiveRenderDuration - a.inclusiveRenderDuration;234  });235}236function getOperations() {237  var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();238  if (!__DEV__) {239    warnInProduction();240    return [];241  }242  var stats = [];243  flushHistory.forEach(function (flush, flushIndex) {244    var operations = flush.operations,245        treeSnapshot = flush.treeSnapshot;246    operations.forEach(function (operation) {247      var instanceID = operation.instanceID,248          type = operation.type,249          payload = operation.payload;250      var _treeSnapshot$instanc3 = treeSnapshot[instanceID],251          displayName = _treeSnapshot$instanc3.displayName,252          ownerID = _treeSnapshot$instanc3.ownerID;253      var owner = treeSnapshot[ownerID];254      var key = (owner ? owner.displayName + ' > ' : '') + displayName;255      stats.push({256        flushIndex: flushIndex,257        instanceID: instanceID,258        key: key,259        type: type,260        ownerID: ownerID,261        payload: payload262      });263    });264  });265  return stats;266}267function printExclusive(flushHistory) {268  if (!__DEV__) {269    warnInProduction();270    return;271  }272  var stats = getExclusive(flushHistory);273  var table = stats.map(function (item) {274    var key = item.key,275        instanceCount = item.instanceCount,276        totalDuration = item.totalDuration;277    var renderCount = item.counts.render || 0;278    var renderDuration = item.durations.render || 0;279    return {280      Component: key,281      'Total time (ms)': roundFloat(totalDuration),282      'Instance count': instanceCount,283      'Total render time (ms)': roundFloat(renderDuration),284      'Average render time (ms)': renderCount ? roundFloat(renderDuration / renderCount) : undefined,285      'Render count': renderCount,286      'Total lifecycle time (ms)': roundFloat(totalDuration - renderDuration)287    };288  });289  consoleTable(table);290}291function printInclusive(flushHistory) {292  if (!__DEV__) {293    warnInProduction();294    return;295  }296  var stats = getInclusive(flushHistory);297  var table = stats.map(function (item) {298    var key = item.key,299        instanceCount = item.instanceCount,300        inclusiveRenderDuration = item.inclusiveRenderDuration,301        renderCount = item.renderCount;302    return {303      'Owner > Component': key,304      'Inclusive render time (ms)': roundFloat(inclusiveRenderDuration),305      'Instance count': instanceCount,306      'Render count': renderCount307    };308  });309  consoleTable(table);310}311function printWasted(flushHistory) {312  if (!__DEV__) {313    warnInProduction();314    return;315  }316  var stats = getWasted(flushHistory);317  var table = stats.map(function (item) {318    var key = item.key,319        instanceCount = item.instanceCount,320        inclusiveRenderDuration = item.inclusiveRenderDuration,321        renderCount = item.renderCount;322    return {323      'Owner > Component': key,324      'Inclusive wasted time (ms)': roundFloat(inclusiveRenderDuration),325      'Instance count': instanceCount,326      'Render count': renderCount327    };328  });329  consoleTable(table);330}331function printOperations(flushHistory) {332  if (!__DEV__) {333    warnInProduction();334    return;335  }336  var stats = getOperations(flushHistory);337  var table = stats.map(function (stat) {338    return {339      'Owner > Node': stat.key,340      Operation: stat.type,341      Payload: typeof stat.payload === 'object' ? JSON.stringify(stat.payload) : stat.payload,342      'Flush index': stat.flushIndex,343      'Owner Component ID': stat.ownerID,344      'DOM Component ID': stat.instanceID345    };346  });347  consoleTable(table);348}349var warnedAboutPrintDOM = false;350function printDOM(measurements) {351  warning(warnedAboutPrintDOM, '`ReactPerf.printDOM(...)` is deprecated. Use ' + '`ReactPerf.printOperations(...)` instead.');352  warnedAboutPrintDOM = true;353  return printOperations(measurements);354}355var warnedAboutGetMeasurementsSummaryMap = false;356function getMeasurementsSummaryMap(measurements) {357  warning(warnedAboutGetMeasurementsSummaryMap, '`ReactPerf.getMeasurementsSummaryMap(...)` is deprecated. Use ' + '`ReactPerf.getWasted(...)` instead.');358  warnedAboutGetMeasurementsSummaryMap = true;359  return getWasted(measurements);360}361function start() {362  if (!__DEV__) {363    warnInProduction();364    return;365  }366  ReactDebugTool.beginProfiling();367}368function stop() {369  if (!__DEV__) {370    warnInProduction();371    return;372  }373  ReactDebugTool.endProfiling();374}375function isRunning() {376  if (!__DEV__) {377    warnInProduction();378    return false;379  }380  return ReactDebugTool.isProfiling();381}382var ReactPerfAnalysis = {383  getLastMeasurements: getLastMeasurements,384  getExclusive: getExclusive,385  getInclusive: getInclusive,386  getWasted: getWasted,387  getOperations: getOperations,388  printExclusive: printExclusive,389  printInclusive: printInclusive,390  printWasted: printWasted,391  printOperations: printOperations,...d2efab3087c06216933343e6f4b71b9bc9dba0ReactPerf.js
Source:d2efab3087c06216933343e6f4b71b9bc9dba0ReactPerf.js  
...9}10function consoleTable(table) {11  console.table(table);12}13function warnInProduction() {14  if (alreadyWarned) {15    return;16  }17  alreadyWarned = true;18  if (typeof console !== 'undefined') {19    console.error('ReactPerf is not supported in the production builds of React. ' + 'To collect measurements, please use the development build of React instead.');20  }21}22function getLastMeasurements() {23  if (!__DEV__) {24    warnInProduction();25    return [];26  }27  return ReactDebugTool.getFlushHistory();28}29function getExclusive() {30  var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();31  if (!__DEV__) {32    warnInProduction();33    return [];34  }35  var aggregatedStats = {};36  var affectedIDs = {};37  function updateAggregatedStats(treeSnapshot, instanceID, timerType, applyUpdate) {38    var displayName = treeSnapshot[instanceID].displayName;39    var key = displayName;40    var stats = aggregatedStats[key];41    if (!stats) {42      affectedIDs[key] = {};43      stats = aggregatedStats[key] = {44        key: key,45        instanceCount: 0,46        counts: {},47        durations: {},48        totalDuration: 049      };50    }51    if (!stats.durations[timerType]) {52      stats.durations[timerType] = 0;53    }54    if (!stats.counts[timerType]) {55      stats.counts[timerType] = 0;56    }57    affectedIDs[key][instanceID] = true;58    applyUpdate(stats);59  }60  flushHistory.forEach(function (flush) {61    var measurements = flush.measurements,62        treeSnapshot = flush.treeSnapshot;63    measurements.forEach(function (measurement) {64      var duration = measurement.duration,65          instanceID = measurement.instanceID,66          timerType = measurement.timerType;67      updateAggregatedStats(treeSnapshot, instanceID, timerType, function (stats) {68        stats.totalDuration += duration;69        stats.durations[timerType] += duration;70        stats.counts[timerType]++;71      });72    });73  });74  return Object.keys(aggregatedStats).map(function (key) {75    return babelHelpers.extends({}, aggregatedStats[key], {76      instanceCount: Object.keys(affectedIDs[key]).length77    });78  }).sort(function (a, b) {79    return b.totalDuration - a.totalDuration;80  });81}82function getInclusive() {83  var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();84  if (!__DEV__) {85    warnInProduction();86    return [];87  }88  var aggregatedStats = {};89  var affectedIDs = {};90  function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {91    var _treeSnapshot$instanc = treeSnapshot[instanceID],92        displayName = _treeSnapshot$instanc.displayName,93        ownerID = _treeSnapshot$instanc.ownerID;94    var owner = treeSnapshot[ownerID];95    var key = (owner ? owner.displayName + ' > ' : '') + displayName;96    var stats = aggregatedStats[key];97    if (!stats) {98      affectedIDs[key] = {};99      stats = aggregatedStats[key] = {100        key: key,101        instanceCount: 0,102        inclusiveRenderDuration: 0,103        renderCount: 0104      };105    }106    affectedIDs[key][instanceID] = true;107    applyUpdate(stats);108  }109  var isCompositeByID = {};110  flushHistory.forEach(function (flush) {111    var measurements = flush.measurements;112    measurements.forEach(function (measurement) {113      var instanceID = measurement.instanceID,114          timerType = measurement.timerType;115      if (timerType !== 'render') {116        return;117      }118      isCompositeByID[instanceID] = true;119    });120  });121  flushHistory.forEach(function (flush) {122    var measurements = flush.measurements,123        treeSnapshot = flush.treeSnapshot;124    measurements.forEach(function (measurement) {125      var duration = measurement.duration,126          instanceID = measurement.instanceID,127          timerType = measurement.timerType;128      if (timerType !== 'render') {129        return;130      }131      updateAggregatedStats(treeSnapshot, instanceID, function (stats) {132        stats.renderCount++;133      });134      var nextParentID = instanceID;135      while (nextParentID) {136        if (isCompositeByID[nextParentID]) {137          updateAggregatedStats(treeSnapshot, nextParentID, function (stats) {138            stats.inclusiveRenderDuration += duration;139          });140        }141        nextParentID = treeSnapshot[nextParentID].parentID;142      }143    });144  });145  return Object.keys(aggregatedStats).map(function (key) {146    return babelHelpers.extends({}, aggregatedStats[key], {147      instanceCount: Object.keys(affectedIDs[key]).length148    });149  }).sort(function (a, b) {150    return b.inclusiveRenderDuration - a.inclusiveRenderDuration;151  });152}153function getWasted() {154  var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();155  if (!__DEV__) {156    warnInProduction();157    return [];158  }159  var aggregatedStats = {};160  var affectedIDs = {};161  function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {162    var _treeSnapshot$instanc2 = treeSnapshot[instanceID],163        displayName = _treeSnapshot$instanc2.displayName,164        ownerID = _treeSnapshot$instanc2.ownerID;165    var owner = treeSnapshot[ownerID];166    var key = (owner ? owner.displayName + ' > ' : '') + displayName;167    var stats = aggregatedStats[key];168    if (!stats) {169      affectedIDs[key] = {};170      stats = aggregatedStats[key] = {171        key: key,172        instanceCount: 0,173        inclusiveRenderDuration: 0,174        renderCount: 0175      };176    }177    affectedIDs[key][instanceID] = true;178    applyUpdate(stats);179  }180  flushHistory.forEach(function (flush) {181    var measurements = flush.measurements,182        treeSnapshot = flush.treeSnapshot,183        operations = flush.operations;184    var isDefinitelyNotWastedByID = {};185    operations.forEach(function (operation) {186      var instanceID = operation.instanceID;187      var nextParentID = instanceID;188      while (nextParentID) {189        isDefinitelyNotWastedByID[nextParentID] = true;190        nextParentID = treeSnapshot[nextParentID].parentID;191      }192    });193    var renderedCompositeIDs = {};194    measurements.forEach(function (measurement) {195      var instanceID = measurement.instanceID,196          timerType = measurement.timerType;197      if (timerType !== 'render') {198        return;199      }200      renderedCompositeIDs[instanceID] = true;201    });202    measurements.forEach(function (measurement) {203      var duration = measurement.duration,204          instanceID = measurement.instanceID,205          timerType = measurement.timerType;206      if (timerType !== 'render') {207        return;208      }209      var updateCount = treeSnapshot[instanceID].updateCount;210      if (isDefinitelyNotWastedByID[instanceID] || updateCount === 0) {211        return;212      }213      updateAggregatedStats(treeSnapshot, instanceID, function (stats) {214        stats.renderCount++;215      });216      var nextParentID = instanceID;217      while (nextParentID) {218        var isWasted = renderedCompositeIDs[nextParentID] && !isDefinitelyNotWastedByID[nextParentID];219        if (isWasted) {220          updateAggregatedStats(treeSnapshot, nextParentID, function (stats) {221            stats.inclusiveRenderDuration += duration;222          });223        }224        nextParentID = treeSnapshot[nextParentID].parentID;225      }226    });227  });228  return Object.keys(aggregatedStats).map(function (key) {229    return babelHelpers.extends({}, aggregatedStats[key], {230      instanceCount: Object.keys(affectedIDs[key]).length231    });232  }).sort(function (a, b) {233    return b.inclusiveRenderDuration - a.inclusiveRenderDuration;234  });235}236function getOperations() {237  var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();238  if (!__DEV__) {239    warnInProduction();240    return [];241  }242  var stats = [];243  flushHistory.forEach(function (flush, flushIndex) {244    var operations = flush.operations,245        treeSnapshot = flush.treeSnapshot;246    operations.forEach(function (operation) {247      var instanceID = operation.instanceID,248          type = operation.type,249          payload = operation.payload;250      var _treeSnapshot$instanc3 = treeSnapshot[instanceID],251          displayName = _treeSnapshot$instanc3.displayName,252          ownerID = _treeSnapshot$instanc3.ownerID;253      var owner = treeSnapshot[ownerID];254      var key = (owner ? owner.displayName + ' > ' : '') + displayName;255      stats.push({256        flushIndex: flushIndex,257        instanceID: instanceID,258        key: key,259        type: type,260        ownerID: ownerID,261        payload: payload262      });263    });264  });265  return stats;266}267function printExclusive(flushHistory) {268  if (!__DEV__) {269    warnInProduction();270    return;271  }272  var stats = getExclusive(flushHistory);273  var table = stats.map(function (item) {274    var key = item.key,275        instanceCount = item.instanceCount,276        totalDuration = item.totalDuration;277    var renderCount = item.counts.render || 0;278    var renderDuration = item.durations.render || 0;279    return {280      Component: key,281      'Total time (ms)': roundFloat(totalDuration),282      'Instance count': instanceCount,283      'Total render time (ms)': roundFloat(renderDuration),284      'Average render time (ms)': renderCount ? roundFloat(renderDuration / renderCount) : undefined,285      'Render count': renderCount,286      'Total lifecycle time (ms)': roundFloat(totalDuration - renderDuration)287    };288  });289  consoleTable(table);290}291function printInclusive(flushHistory) {292  if (!__DEV__) {293    warnInProduction();294    return;295  }296  var stats = getInclusive(flushHistory);297  var table = stats.map(function (item) {298    var key = item.key,299        instanceCount = item.instanceCount,300        inclusiveRenderDuration = item.inclusiveRenderDuration,301        renderCount = item.renderCount;302    return {303      'Owner > Component': key,304      'Inclusive render time (ms)': roundFloat(inclusiveRenderDuration),305      'Instance count': instanceCount,306      'Render count': renderCount307    };308  });309  consoleTable(table);310}311function printWasted(flushHistory) {312  if (!__DEV__) {313    warnInProduction();314    return;315  }316  var stats = getWasted(flushHistory);317  var table = stats.map(function (item) {318    var key = item.key,319        instanceCount = item.instanceCount,320        inclusiveRenderDuration = item.inclusiveRenderDuration,321        renderCount = item.renderCount;322    return {323      'Owner > Component': key,324      'Inclusive wasted time (ms)': roundFloat(inclusiveRenderDuration),325      'Instance count': instanceCount,326      'Render count': renderCount327    };328  });329  consoleTable(table);330}331function printOperations(flushHistory) {332  if (!__DEV__) {333    warnInProduction();334    return;335  }336  var stats = getOperations(flushHistory);337  var table = stats.map(function (stat) {338    return {339      'Owner > Node': stat.key,340      Operation: stat.type,341      Payload: typeof stat.payload === 'object' ? JSON.stringify(stat.payload) : stat.payload,342      'Flush index': stat.flushIndex,343      'Owner Component ID': stat.ownerID,344      'DOM Component ID': stat.instanceID345    };346  });347  consoleTable(table);348}349var warnedAboutPrintDOM = false;350function printDOM(measurements) {351  warning(warnedAboutPrintDOM, '`ReactPerf.printDOM(...)` is deprecated. Use ' + '`ReactPerf.printOperations(...)` instead.');352  warnedAboutPrintDOM = true;353  return printOperations(measurements);354}355var warnedAboutGetMeasurementsSummaryMap = false;356function getMeasurementsSummaryMap(measurements) {357  warning(warnedAboutGetMeasurementsSummaryMap, '`ReactPerf.getMeasurementsSummaryMap(...)` is deprecated. Use ' + '`ReactPerf.getWasted(...)` instead.');358  warnedAboutGetMeasurementsSummaryMap = true;359  return getWasted(measurements);360}361function start() {362  if (!__DEV__) {363    warnInProduction();364    return;365  }366  ReactDebugTool.beginProfiling();367}368function stop() {369  if (!__DEV__) {370    warnInProduction();371    return;372  }373  ReactDebugTool.endProfiling();374}375function isRunning() {376  if (!__DEV__) {377    warnInProduction();378    return false;379  }380  return ReactDebugTool.isProfiling();381}382var ReactPerfAnalysis = {383  getLastMeasurements: getLastMeasurements,384  getExclusive: getExclusive,385  getInclusive: getInclusive,386  getWasted: getWasted,387  getOperations: getOperations,388  printExclusive: printExclusive,389  printInclusive: printInclusive,390  printWasted: printWasted,391  printOperations: printOperations,...44faf03d3215f1255542ab8cd23e8eca803308ReactPerf.js
Source:44faf03d3215f1255542ab8cd23e8eca803308ReactPerf.js  
...9}10function consoleTable(table) {11  console.table(table);12}13function warnInProduction() {14  if (alreadyWarned) {15    return;16  }17  alreadyWarned = true;18  if (typeof console !== 'undefined') {19    console.error('ReactPerf is not supported in the production builds of React. ' + 'To collect measurements, please use the development build of React instead.');20  }21}22function getLastMeasurements() {23  if (!__DEV__) {24    warnInProduction();25    return [];26  }27  return ReactDebugTool.getFlushHistory();28}29function getExclusive() {30  var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();31  if (!__DEV__) {32    warnInProduction();33    return [];34  }35  var aggregatedStats = {};36  var affectedIDs = {};37  function updateAggregatedStats(treeSnapshot, instanceID, timerType, applyUpdate) {38    var displayName = treeSnapshot[instanceID].displayName;39    var key = displayName;40    var stats = aggregatedStats[key];41    if (!stats) {42      affectedIDs[key] = {};43      stats = aggregatedStats[key] = {44        key: key,45        instanceCount: 0,46        counts: {},47        durations: {},48        totalDuration: 049      };50    }51    if (!stats.durations[timerType]) {52      stats.durations[timerType] = 0;53    }54    if (!stats.counts[timerType]) {55      stats.counts[timerType] = 0;56    }57    affectedIDs[key][instanceID] = true;58    applyUpdate(stats);59  }60  flushHistory.forEach(function (flush) {61    var measurements = flush.measurements,62        treeSnapshot = flush.treeSnapshot;63    measurements.forEach(function (measurement) {64      var duration = measurement.duration,65          instanceID = measurement.instanceID,66          timerType = measurement.timerType;67      updateAggregatedStats(treeSnapshot, instanceID, timerType, function (stats) {68        stats.totalDuration += duration;69        stats.durations[timerType] += duration;70        stats.counts[timerType]++;71      });72    });73  });74  return Object.keys(aggregatedStats).map(function (key) {75    return babelHelpers.extends({}, aggregatedStats[key], {76      instanceCount: Object.keys(affectedIDs[key]).length77    });78  }).sort(function (a, b) {79    return b.totalDuration - a.totalDuration;80  });81}82function getInclusive() {83  var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();84  if (!__DEV__) {85    warnInProduction();86    return [];87  }88  var aggregatedStats = {};89  var affectedIDs = {};90  function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {91    var _treeSnapshot$instanc = treeSnapshot[instanceID],92        displayName = _treeSnapshot$instanc.displayName,93        ownerID = _treeSnapshot$instanc.ownerID;94    var owner = treeSnapshot[ownerID];95    var key = (owner ? owner.displayName + ' > ' : '') + displayName;96    var stats = aggregatedStats[key];97    if (!stats) {98      affectedIDs[key] = {};99      stats = aggregatedStats[key] = {100        key: key,101        instanceCount: 0,102        inclusiveRenderDuration: 0,103        renderCount: 0104      };105    }106    affectedIDs[key][instanceID] = true;107    applyUpdate(stats);108  }109  var isCompositeByID = {};110  flushHistory.forEach(function (flush) {111    var measurements = flush.measurements;112    measurements.forEach(function (measurement) {113      var instanceID = measurement.instanceID,114          timerType = measurement.timerType;115      if (timerType !== 'render') {116        return;117      }118      isCompositeByID[instanceID] = true;119    });120  });121  flushHistory.forEach(function (flush) {122    var measurements = flush.measurements,123        treeSnapshot = flush.treeSnapshot;124    measurements.forEach(function (measurement) {125      var duration = measurement.duration,126          instanceID = measurement.instanceID,127          timerType = measurement.timerType;128      if (timerType !== 'render') {129        return;130      }131      updateAggregatedStats(treeSnapshot, instanceID, function (stats) {132        stats.renderCount++;133      });134      var nextParentID = instanceID;135      while (nextParentID) {136        if (isCompositeByID[nextParentID]) {137          updateAggregatedStats(treeSnapshot, nextParentID, function (stats) {138            stats.inclusiveRenderDuration += duration;139          });140        }141        nextParentID = treeSnapshot[nextParentID].parentID;142      }143    });144  });145  return Object.keys(aggregatedStats).map(function (key) {146    return babelHelpers.extends({}, aggregatedStats[key], {147      instanceCount: Object.keys(affectedIDs[key]).length148    });149  }).sort(function (a, b) {150    return b.inclusiveRenderDuration - a.inclusiveRenderDuration;151  });152}153function getWasted() {154  var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();155  if (!__DEV__) {156    warnInProduction();157    return [];158  }159  var aggregatedStats = {};160  var affectedIDs = {};161  function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {162    var _treeSnapshot$instanc2 = treeSnapshot[instanceID],163        displayName = _treeSnapshot$instanc2.displayName,164        ownerID = _treeSnapshot$instanc2.ownerID;165    var owner = treeSnapshot[ownerID];166    var key = (owner ? owner.displayName + ' > ' : '') + displayName;167    var stats = aggregatedStats[key];168    if (!stats) {169      affectedIDs[key] = {};170      stats = aggregatedStats[key] = {171        key: key,172        instanceCount: 0,173        inclusiveRenderDuration: 0,174        renderCount: 0175      };176    }177    affectedIDs[key][instanceID] = true;178    applyUpdate(stats);179  }180  flushHistory.forEach(function (flush) {181    var measurements = flush.measurements,182        treeSnapshot = flush.treeSnapshot,183        operations = flush.operations;184    var isDefinitelyNotWastedByID = {};185    operations.forEach(function (operation) {186      var instanceID = operation.instanceID;187      var nextParentID = instanceID;188      while (nextParentID) {189        isDefinitelyNotWastedByID[nextParentID] = true;190        nextParentID = treeSnapshot[nextParentID].parentID;191      }192    });193    var renderedCompositeIDs = {};194    measurements.forEach(function (measurement) {195      var instanceID = measurement.instanceID,196          timerType = measurement.timerType;197      if (timerType !== 'render') {198        return;199      }200      renderedCompositeIDs[instanceID] = true;201    });202    measurements.forEach(function (measurement) {203      var duration = measurement.duration,204          instanceID = measurement.instanceID,205          timerType = measurement.timerType;206      if (timerType !== 'render') {207        return;208      }209      var updateCount = treeSnapshot[instanceID].updateCount;210      if (isDefinitelyNotWastedByID[instanceID] || updateCount === 0) {211        return;212      }213      updateAggregatedStats(treeSnapshot, instanceID, function (stats) {214        stats.renderCount++;215      });216      var nextParentID = instanceID;217      while (nextParentID) {218        var isWasted = renderedCompositeIDs[nextParentID] && !isDefinitelyNotWastedByID[nextParentID];219        if (isWasted) {220          updateAggregatedStats(treeSnapshot, nextParentID, function (stats) {221            stats.inclusiveRenderDuration += duration;222          });223        }224        nextParentID = treeSnapshot[nextParentID].parentID;225      }226    });227  });228  return Object.keys(aggregatedStats).map(function (key) {229    return babelHelpers.extends({}, aggregatedStats[key], {230      instanceCount: Object.keys(affectedIDs[key]).length231    });232  }).sort(function (a, b) {233    return b.inclusiveRenderDuration - a.inclusiveRenderDuration;234  });235}236function getOperations() {237  var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();238  if (!__DEV__) {239    warnInProduction();240    return [];241  }242  var stats = [];243  flushHistory.forEach(function (flush, flushIndex) {244    var operations = flush.operations,245        treeSnapshot = flush.treeSnapshot;246    operations.forEach(function (operation) {247      var instanceID = operation.instanceID,248          type = operation.type,249          payload = operation.payload;250      var _treeSnapshot$instanc3 = treeSnapshot[instanceID],251          displayName = _treeSnapshot$instanc3.displayName,252          ownerID = _treeSnapshot$instanc3.ownerID;253      var owner = treeSnapshot[ownerID];254      var key = (owner ? owner.displayName + ' > ' : '') + displayName;255      stats.push({256        flushIndex: flushIndex,257        instanceID: instanceID,258        key: key,259        type: type,260        ownerID: ownerID,261        payload: payload262      });263    });264  });265  return stats;266}267function printExclusive(flushHistory) {268  if (!__DEV__) {269    warnInProduction();270    return;271  }272  var stats = getExclusive(flushHistory);273  var table = stats.map(function (item) {274    var key = item.key,275        instanceCount = item.instanceCount,276        totalDuration = item.totalDuration;277    var renderCount = item.counts.render || 0;278    var renderDuration = item.durations.render || 0;279    return {280      Component: key,281      'Total time (ms)': roundFloat(totalDuration),282      'Instance count': instanceCount,283      'Total render time (ms)': roundFloat(renderDuration),284      'Average render time (ms)': renderCount ? roundFloat(renderDuration / renderCount) : undefined,285      'Render count': renderCount,286      'Total lifecycle time (ms)': roundFloat(totalDuration - renderDuration)287    };288  });289  consoleTable(table);290}291function printInclusive(flushHistory) {292  if (!__DEV__) {293    warnInProduction();294    return;295  }296  var stats = getInclusive(flushHistory);297  var table = stats.map(function (item) {298    var key = item.key,299        instanceCount = item.instanceCount,300        inclusiveRenderDuration = item.inclusiveRenderDuration,301        renderCount = item.renderCount;302    return {303      'Owner > Component': key,304      'Inclusive render time (ms)': roundFloat(inclusiveRenderDuration),305      'Instance count': instanceCount,306      'Render count': renderCount307    };308  });309  consoleTable(table);310}311function printWasted(flushHistory) {312  if (!__DEV__) {313    warnInProduction();314    return;315  }316  var stats = getWasted(flushHistory);317  var table = stats.map(function (item) {318    var key = item.key,319        instanceCount = item.instanceCount,320        inclusiveRenderDuration = item.inclusiveRenderDuration,321        renderCount = item.renderCount;322    return {323      'Owner > Component': key,324      'Inclusive wasted time (ms)': roundFloat(inclusiveRenderDuration),325      'Instance count': instanceCount,326      'Render count': renderCount327    };328  });329  consoleTable(table);330}331function printOperations(flushHistory) {332  if (!__DEV__) {333    warnInProduction();334    return;335  }336  var stats = getOperations(flushHistory);337  var table = stats.map(function (stat) {338    return {339      'Owner > Node': stat.key,340      Operation: stat.type,341      Payload: typeof stat.payload === 'object' ? JSON.stringify(stat.payload) : stat.payload,342      'Flush index': stat.flushIndex,343      'Owner Component ID': stat.ownerID,344      'DOM Component ID': stat.instanceID345    };346  });347  consoleTable(table);348}349var warnedAboutPrintDOM = false;350function printDOM(measurements) {351  warning(warnedAboutPrintDOM, '`ReactPerf.printDOM(...)` is deprecated. Use ' + '`ReactPerf.printOperations(...)` instead.');352  warnedAboutPrintDOM = true;353  return printOperations(measurements);354}355var warnedAboutGetMeasurementsSummaryMap = false;356function getMeasurementsSummaryMap(measurements) {357  warning(warnedAboutGetMeasurementsSummaryMap, '`ReactPerf.getMeasurementsSummaryMap(...)` is deprecated. Use ' + '`ReactPerf.getWasted(...)` instead.');358  warnedAboutGetMeasurementsSummaryMap = true;359  return getWasted(measurements);360}361function start() {362  if (!__DEV__) {363    warnInProduction();364    return;365  }366  ReactDebugTool.beginProfiling();367}368function stop() {369  if (!__DEV__) {370    warnInProduction();371    return;372  }373  ReactDebugTool.endProfiling();374}375function isRunning() {376  if (!__DEV__) {377    warnInProduction();378    return false;379  }380  return ReactDebugTool.isProfiling();381}382var ReactPerfAnalysis = {383  getLastMeasurements: getLastMeasurements,384  getExclusive: getExclusive,385  getInclusive: getInclusive,386  getWasted: getWasted,387  getOperations: getOperations,388  printExclusive: printExclusive,389  printInclusive: printInclusive,390  printWasted: printWasted,391  printOperations: printOperations,...711832ReactPerf.js
Source:711832ReactPerf.js  
...8}9function consoleTable(table){10console.table(table);11}12function warnInProduction(){13if(alreadyWarned){14return;15}16alreadyWarned=true;17if(typeof console!=='undefined'){18console.error(19'ReactPerf is not supported in the production builds of React. '+20'To collect measurements, please use the development build of React instead.');21}22}23function getLastMeasurements(){24if(!__DEV__){25warnInProduction();26return[];27}28return ReactDebugTool.getFlushHistory();29}30function getExclusive(){var flushHistory=arguments.length>0&&arguments[0]!==undefined?arguments[0]:getLastMeasurements();31if(!__DEV__){32warnInProduction();33return[];34}35var aggregatedStats={};36var affectedIDs={};37function updateAggregatedStats(treeSnapshot,instanceID,timerType,applyUpdate){var38displayName=treeSnapshot[instanceID].displayName;39var key=displayName;40var stats=aggregatedStats[key];41if(!stats){42affectedIDs[key]={};43stats=aggregatedStats[key]={44key:key,45instanceCount:0,46counts:{},47durations:{},48totalDuration:0};49}50if(!stats.durations[timerType]){51stats.durations[timerType]=0;52}53if(!stats.counts[timerType]){54stats.counts[timerType]=0;55}56affectedIDs[key][instanceID]=true;57applyUpdate(stats);58}59flushHistory.forEach(function(flush){var60measurements=flush.measurements,treeSnapshot=flush.treeSnapshot;61measurements.forEach(function(measurement){var62duration=measurement.duration,instanceID=measurement.instanceID,timerType=measurement.timerType;63updateAggregatedStats(treeSnapshot,instanceID,timerType,function(stats){64stats.totalDuration+=duration;65stats.durations[timerType]+=duration;66stats.counts[timerType]++;67});68});69});70return Object.keys(aggregatedStats).71map(function(key){return babelHelpers.extends({},72aggregatedStats[key],{73instanceCount:Object.keys(affectedIDs[key]).length});}).74sort(function(a,b){return(75b.totalDuration-a.totalDuration);});76}77function getInclusive(){var flushHistory=arguments.length>0&&arguments[0]!==undefined?arguments[0]:getLastMeasurements();78if(!__DEV__){79warnInProduction();80return[];81}82var aggregatedStats={};83var affectedIDs={};84function updateAggregatedStats(treeSnapshot,instanceID,applyUpdate){var _treeSnapshot$instanc=85treeSnapshot[instanceID],displayName=_treeSnapshot$instanc.displayName,ownerID=_treeSnapshot$instanc.ownerID;86var owner=treeSnapshot[ownerID];87var key=(owner?owner.displayName+' > ':'')+displayName;88var stats=aggregatedStats[key];89if(!stats){90affectedIDs[key]={};91stats=aggregatedStats[key]={92key:key,93instanceCount:0,94inclusiveRenderDuration:0,95renderCount:0};96}97affectedIDs[key][instanceID]=true;98applyUpdate(stats);99}100var isCompositeByID={};101flushHistory.forEach(function(flush){var102measurements=flush.measurements;103measurements.forEach(function(measurement){var104instanceID=measurement.instanceID,timerType=measurement.timerType;105if(timerType!=='render'){106return;107}108isCompositeByID[instanceID]=true;109});110});111flushHistory.forEach(function(flush){var112measurements=flush.measurements,treeSnapshot=flush.treeSnapshot;113measurements.forEach(function(measurement){var114duration=measurement.duration,instanceID=measurement.instanceID,timerType=measurement.timerType;115if(timerType!=='render'){116return;117}118updateAggregatedStats(treeSnapshot,instanceID,function(stats){119stats.renderCount++;120});121var nextParentID=instanceID;122while(nextParentID){123if(isCompositeByID[nextParentID]){124updateAggregatedStats(treeSnapshot,nextParentID,function(stats){125stats.inclusiveRenderDuration+=duration;126});127}128nextParentID=treeSnapshot[nextParentID].parentID;129}130});131});132return Object.keys(aggregatedStats).133map(function(key){return babelHelpers.extends({},134aggregatedStats[key],{135instanceCount:Object.keys(affectedIDs[key]).length});}).136sort(function(a,b){return(137b.inclusiveRenderDuration-a.inclusiveRenderDuration);});138}139function getWasted(){var flushHistory=arguments.length>0&&arguments[0]!==undefined?arguments[0]:getLastMeasurements();140if(!__DEV__){141warnInProduction();142return[];143}144var aggregatedStats={};145var affectedIDs={};146function updateAggregatedStats(treeSnapshot,instanceID,applyUpdate){var _treeSnapshot$instanc2=147treeSnapshot[instanceID],displayName=_treeSnapshot$instanc2.displayName,ownerID=_treeSnapshot$instanc2.ownerID;148var owner=treeSnapshot[ownerID];149var key=(owner?owner.displayName+' > ':'')+displayName;150var stats=aggregatedStats[key];151if(!stats){152affectedIDs[key]={};153stats=aggregatedStats[key]={154key:key,155instanceCount:0,156inclusiveRenderDuration:0,157renderCount:0};158}159affectedIDs[key][instanceID]=true;160applyUpdate(stats);161}162flushHistory.forEach(function(flush){var163measurements=flush.measurements,treeSnapshot=flush.treeSnapshot,operations=flush.operations;164var isDefinitelyNotWastedByID={};165operations.forEach(function(operation){var166instanceID=operation.instanceID;167var nextParentID=instanceID;168while(nextParentID){169isDefinitelyNotWastedByID[nextParentID]=true;170nextParentID=treeSnapshot[nextParentID].parentID;171}172});173var renderedCompositeIDs={};174measurements.forEach(function(measurement){var175instanceID=measurement.instanceID,timerType=measurement.timerType;176if(timerType!=='render'){177return;178}179renderedCompositeIDs[instanceID]=true;180});181measurements.forEach(function(measurement){var182duration=measurement.duration,instanceID=measurement.instanceID,timerType=measurement.timerType;183if(timerType!=='render'){184return;185}var186updateCount=treeSnapshot[instanceID].updateCount;187if(isDefinitelyNotWastedByID[instanceID]||updateCount===0){188return;189}190updateAggregatedStats(treeSnapshot,instanceID,function(stats){191stats.renderCount++;192});193var nextParentID=instanceID;194while(nextParentID){195var isWasted=196renderedCompositeIDs[nextParentID]&&197!isDefinitelyNotWastedByID[nextParentID];198if(isWasted){199updateAggregatedStats(treeSnapshot,nextParentID,function(stats){200stats.inclusiveRenderDuration+=duration;201});202}203nextParentID=treeSnapshot[nextParentID].parentID;204}205});206});207return Object.keys(aggregatedStats).208map(function(key){return babelHelpers.extends({},209aggregatedStats[key],{210instanceCount:Object.keys(affectedIDs[key]).length});}).211sort(function(a,b){return(212b.inclusiveRenderDuration-a.inclusiveRenderDuration);});213}214function getOperations(){var flushHistory=arguments.length>0&&arguments[0]!==undefined?arguments[0]:getLastMeasurements();215if(!__DEV__){216warnInProduction();217return[];218}219var stats=[];220flushHistory.forEach(function(flush,flushIndex){var221operations=flush.operations,treeSnapshot=flush.treeSnapshot;222operations.forEach(function(operation){var223instanceID=operation.instanceID,type=operation.type,payload=operation.payload;var _treeSnapshot$instanc3=224treeSnapshot[instanceID],displayName=_treeSnapshot$instanc3.displayName,ownerID=_treeSnapshot$instanc3.ownerID;225var owner=treeSnapshot[ownerID];226var key=(owner?owner.displayName+' > ':'')+displayName;227stats.push({228flushIndex:flushIndex,229instanceID:instanceID,230key:key,231type:type,232ownerID:ownerID,233payload:payload});234});235});236return stats;237}238function printExclusive(flushHistory){239if(!__DEV__){240warnInProduction();241return;242}243var stats=getExclusive(flushHistory);244var table=stats.map(function(item){var245key=item.key,instanceCount=item.instanceCount,totalDuration=item.totalDuration;246var renderCount=item.counts.render||0;247var renderDuration=item.durations.render||0;248return{249'Component':key,250'Total time (ms)':roundFloat(totalDuration),251'Instance count':instanceCount,252'Total render time (ms)':roundFloat(renderDuration),253'Average render time (ms)':renderCount?254roundFloat(renderDuration/renderCount):255undefined,256'Render count':renderCount,257'Total lifecycle time (ms)':roundFloat(totalDuration-renderDuration)};258});259consoleTable(table);260}261function printInclusive(flushHistory){262if(!__DEV__){263warnInProduction();264return;265}266var stats=getInclusive(flushHistory);267var table=stats.map(function(item){var268key=item.key,instanceCount=item.instanceCount,inclusiveRenderDuration=item.inclusiveRenderDuration,renderCount=item.renderCount;269return{270'Owner > Component':key,271'Inclusive render time (ms)':roundFloat(inclusiveRenderDuration),272'Instance count':instanceCount,273'Render count':renderCount};274});275consoleTable(table);276}277function printWasted(flushHistory){278if(!__DEV__){279warnInProduction();280return;281}282var stats=getWasted(flushHistory);283var table=stats.map(function(item){var284key=item.key,instanceCount=item.instanceCount,inclusiveRenderDuration=item.inclusiveRenderDuration,renderCount=item.renderCount;285return{286'Owner > Component':key,287'Inclusive wasted time (ms)':roundFloat(inclusiveRenderDuration),288'Instance count':instanceCount,289'Render count':renderCount};290});291consoleTable(table);292}293function printOperations(flushHistory){294if(!__DEV__){295warnInProduction();296return;297}298var stats=getOperations(flushHistory);299var table=stats.map(function(stat){return{300'Owner > Node':stat.key,301'Operation':stat.type,302'Payload':typeof stat.payload==='object'?303JSON.stringify(stat.payload):304stat.payload,305'Flush index':stat.flushIndex,306'Owner Component ID':stat.ownerID,307'DOM Component ID':stat.instanceID};});308consoleTable(table);309}310var warnedAboutPrintDOM=false;311function printDOM(measurements){312warning(313warnedAboutPrintDOM,314'`ReactPerf.printDOM(...)` is deprecated. Use '+315'`ReactPerf.printOperations(...)` instead.');316warnedAboutPrintDOM=true;317return printOperations(measurements);318}319var warnedAboutGetMeasurementsSummaryMap=false;320function getMeasurementsSummaryMap(measurements){321warning(322warnedAboutGetMeasurementsSummaryMap,323'`ReactPerf.getMeasurementsSummaryMap(...)` is deprecated. Use '+324'`ReactPerf.getWasted(...)` instead.');325warnedAboutGetMeasurementsSummaryMap=true;326return getWasted(measurements);327}328function start(){329if(!__DEV__){330warnInProduction();331return;332}333ReactDebugTool.beginProfiling();334}335function stop(){336if(!__DEV__){337warnInProduction();338return;339}340ReactDebugTool.endProfiling();341}342function isRunning(){343if(!__DEV__){344warnInProduction();345return false;346}347return ReactDebugTool.isProfiling();348}349var ReactPerfAnalysis={350getLastMeasurements:getLastMeasurements,351getExclusive:getExclusive,352getInclusive:getInclusive,353getWasted:getWasted,354getOperations:getOperations,355printExclusive:printExclusive,356printInclusive:printInclusive,357printWasted:printWasted,358printOperations:printOperations,...6558d0ReactPerf.js
Source:6558d0ReactPerf.js  
...8}9function consoleTable(table){10console.table(table);11}12function warnInProduction(){13if(alreadyWarned){14return;15}16alreadyWarned=true;17if(typeof console!=='undefined'){18console.error(19'ReactPerf is not supported in the production builds of React. '+20'To collect measurements, please use the development build of React instead.');21}22}23function getLastMeasurements(){24if(!__DEV__){25warnInProduction();26return[];27}28return ReactDebugTool.getFlushHistory();29}30function getExclusive(){var flushHistory=arguments.length>0&&arguments[0]!==undefined?arguments[0]:getLastMeasurements();31if(!__DEV__){32warnInProduction();33return[];34}35var aggregatedStats={};36var affectedIDs={};37function updateAggregatedStats(treeSnapshot,instanceID,timerType,applyUpdate){var38displayName=treeSnapshot[instanceID].displayName;39var key=displayName;40var stats=aggregatedStats[key];41if(!stats){42affectedIDs[key]={};43stats=aggregatedStats[key]={44key:key,45instanceCount:0,46counts:{},47durations:{},48totalDuration:0};49}50if(!stats.durations[timerType]){51stats.durations[timerType]=0;52}53if(!stats.counts[timerType]){54stats.counts[timerType]=0;55}56affectedIDs[key][instanceID]=true;57applyUpdate(stats);58}59flushHistory.forEach(function(flush){var60measurements=flush.measurements,treeSnapshot=flush.treeSnapshot;61measurements.forEach(function(measurement){var62duration=measurement.duration,instanceID=measurement.instanceID,timerType=measurement.timerType;63updateAggregatedStats(treeSnapshot,instanceID,timerType,function(stats){64stats.totalDuration+=duration;65stats.durations[timerType]+=duration;66stats.counts[timerType]++;67});68});69});70return Object.keys(aggregatedStats).71map(function(key){return babelHelpers.extends({},72aggregatedStats[key],{73instanceCount:Object.keys(affectedIDs[key]).length});}).74sort(function(a,b){return(75b.totalDuration-a.totalDuration);});76}77function getInclusive(){var flushHistory=arguments.length>0&&arguments[0]!==undefined?arguments[0]:getLastMeasurements();78if(!__DEV__){79warnInProduction();80return[];81}82var aggregatedStats={};83var affectedIDs={};84function updateAggregatedStats(treeSnapshot,instanceID,applyUpdate){var _treeSnapshot$instanc=85treeSnapshot[instanceID],displayName=_treeSnapshot$instanc.displayName,ownerID=_treeSnapshot$instanc.ownerID;86var owner=treeSnapshot[ownerID];87var key=(owner?owner.displayName+' > ':'')+displayName;88var stats=aggregatedStats[key];89if(!stats){90affectedIDs[key]={};91stats=aggregatedStats[key]={92key:key,93instanceCount:0,94inclusiveRenderDuration:0,95renderCount:0};96}97affectedIDs[key][instanceID]=true;98applyUpdate(stats);99}100var isCompositeByID={};101flushHistory.forEach(function(flush){var102measurements=flush.measurements;103measurements.forEach(function(measurement){var104instanceID=measurement.instanceID,timerType=measurement.timerType;105if(timerType!=='render'){106return;107}108isCompositeByID[instanceID]=true;109});110});111flushHistory.forEach(function(flush){var112measurements=flush.measurements,treeSnapshot=flush.treeSnapshot;113measurements.forEach(function(measurement){var114duration=measurement.duration,instanceID=measurement.instanceID,timerType=measurement.timerType;115if(timerType!=='render'){116return;117}118updateAggregatedStats(treeSnapshot,instanceID,function(stats){119stats.renderCount++;120});121var nextParentID=instanceID;122while(nextParentID){123if(isCompositeByID[nextParentID]){124updateAggregatedStats(treeSnapshot,nextParentID,function(stats){125stats.inclusiveRenderDuration+=duration;126});127}128nextParentID=treeSnapshot[nextParentID].parentID;129}130});131});132return Object.keys(aggregatedStats).133map(function(key){return babelHelpers.extends({},134aggregatedStats[key],{135instanceCount:Object.keys(affectedIDs[key]).length});}).136sort(function(a,b){return(137b.inclusiveRenderDuration-a.inclusiveRenderDuration);});138}139function getWasted(){var flushHistory=arguments.length>0&&arguments[0]!==undefined?arguments[0]:getLastMeasurements();140if(!__DEV__){141warnInProduction();142return[];143}144var aggregatedStats={};145var affectedIDs={};146function updateAggregatedStats(treeSnapshot,instanceID,applyUpdate){var _treeSnapshot$instanc2=147treeSnapshot[instanceID],displayName=_treeSnapshot$instanc2.displayName,ownerID=_treeSnapshot$instanc2.ownerID;148var owner=treeSnapshot[ownerID];149var key=(owner?owner.displayName+' > ':'')+displayName;150var stats=aggregatedStats[key];151if(!stats){152affectedIDs[key]={};153stats=aggregatedStats[key]={154key:key,155instanceCount:0,156inclusiveRenderDuration:0,157renderCount:0};158}159affectedIDs[key][instanceID]=true;160applyUpdate(stats);161}162flushHistory.forEach(function(flush){var163measurements=flush.measurements,treeSnapshot=flush.treeSnapshot,operations=flush.operations;164var isDefinitelyNotWastedByID={};165operations.forEach(function(operation){var166instanceID=operation.instanceID;167var nextParentID=instanceID;168while(nextParentID){169isDefinitelyNotWastedByID[nextParentID]=true;170nextParentID=treeSnapshot[nextParentID].parentID;171}172});173var renderedCompositeIDs={};174measurements.forEach(function(measurement){var175instanceID=measurement.instanceID,timerType=measurement.timerType;176if(timerType!=='render'){177return;178}179renderedCompositeIDs[instanceID]=true;180});181measurements.forEach(function(measurement){var182duration=measurement.duration,instanceID=measurement.instanceID,timerType=measurement.timerType;183if(timerType!=='render'){184return;185}var186updateCount=treeSnapshot[instanceID].updateCount;187if(isDefinitelyNotWastedByID[instanceID]||updateCount===0){188return;189}190updateAggregatedStats(treeSnapshot,instanceID,function(stats){191stats.renderCount++;192});193var nextParentID=instanceID;194while(nextParentID){195var isWasted=196renderedCompositeIDs[nextParentID]&&197!isDefinitelyNotWastedByID[nextParentID];198if(isWasted){199updateAggregatedStats(treeSnapshot,nextParentID,function(stats){200stats.inclusiveRenderDuration+=duration;201});202}203nextParentID=treeSnapshot[nextParentID].parentID;204}205});206});207return Object.keys(aggregatedStats).208map(function(key){return babelHelpers.extends({},209aggregatedStats[key],{210instanceCount:Object.keys(affectedIDs[key]).length});}).211sort(function(a,b){return(212b.inclusiveRenderDuration-a.inclusiveRenderDuration);});213}214function getOperations(){var flushHistory=arguments.length>0&&arguments[0]!==undefined?arguments[0]:getLastMeasurements();215if(!__DEV__){216warnInProduction();217return[];218}219var stats=[];220flushHistory.forEach(function(flush,flushIndex){var221operations=flush.operations,treeSnapshot=flush.treeSnapshot;222operations.forEach(function(operation){var223instanceID=operation.instanceID,type=operation.type,payload=operation.payload;var _treeSnapshot$instanc3=224treeSnapshot[instanceID],displayName=_treeSnapshot$instanc3.displayName,ownerID=_treeSnapshot$instanc3.ownerID;225var owner=treeSnapshot[ownerID];226var key=(owner?owner.displayName+' > ':'')+displayName;227stats.push({228flushIndex:flushIndex,229instanceID:instanceID,230key:key,231type:type,232ownerID:ownerID,233payload:payload});234});235});236return stats;237}238function printExclusive(flushHistory){239if(!__DEV__){240warnInProduction();241return;242}243var stats=getExclusive(flushHistory);244var table=stats.map(function(item){var245key=item.key,instanceCount=item.instanceCount,totalDuration=item.totalDuration;246var renderCount=item.counts.render||0;247var renderDuration=item.durations.render||0;248return{249'Component':key,250'Total time (ms)':roundFloat(totalDuration),251'Instance count':instanceCount,252'Total render time (ms)':roundFloat(renderDuration),253'Average render time (ms)':renderCount?254roundFloat(renderDuration/renderCount):255undefined,256'Render count':renderCount,257'Total lifecycle time (ms)':roundFloat(totalDuration-renderDuration)};258});259consoleTable(table);260}261function printInclusive(flushHistory){262if(!__DEV__){263warnInProduction();264return;265}266var stats=getInclusive(flushHistory);267var table=stats.map(function(item){var268key=item.key,instanceCount=item.instanceCount,inclusiveRenderDuration=item.inclusiveRenderDuration,renderCount=item.renderCount;269return{270'Owner > Component':key,271'Inclusive render time (ms)':roundFloat(inclusiveRenderDuration),272'Instance count':instanceCount,273'Render count':renderCount};274});275consoleTable(table);276}277function printWasted(flushHistory){278if(!__DEV__){279warnInProduction();280return;281}282var stats=getWasted(flushHistory);283var table=stats.map(function(item){var284key=item.key,instanceCount=item.instanceCount,inclusiveRenderDuration=item.inclusiveRenderDuration,renderCount=item.renderCount;285return{286'Owner > Component':key,287'Inclusive wasted time (ms)':roundFloat(inclusiveRenderDuration),288'Instance count':instanceCount,289'Render count':renderCount};290});291consoleTable(table);292}293function printOperations(flushHistory){294if(!__DEV__){295warnInProduction();296return;297}298var stats=getOperations(flushHistory);299var table=stats.map(function(stat){return{300'Owner > Node':stat.key,301'Operation':stat.type,302'Payload':typeof stat.payload==='object'?303JSON.stringify(stat.payload):304stat.payload,305'Flush index':stat.flushIndex,306'Owner Component ID':stat.ownerID,307'DOM Component ID':stat.instanceID};});308consoleTable(table);309}310var warnedAboutPrintDOM=false;311function printDOM(measurements){312warning(313warnedAboutPrintDOM,314'`ReactPerf.printDOM(...)` is deprecated. Use '+315'`ReactPerf.printOperations(...)` instead.');316warnedAboutPrintDOM=true;317return printOperations(measurements);318}319var warnedAboutGetMeasurementsSummaryMap=false;320function getMeasurementsSummaryMap(measurements){321warning(322warnedAboutGetMeasurementsSummaryMap,323'`ReactPerf.getMeasurementsSummaryMap(...)` is deprecated. Use '+324'`ReactPerf.getWasted(...)` instead.');325warnedAboutGetMeasurementsSummaryMap=true;326return getWasted(measurements);327}328function start(){329if(!__DEV__){330warnInProduction();331return;332}333ReactDebugTool.beginProfiling();334}335function stop(){336if(!__DEV__){337warnInProduction();338return;339}340ReactDebugTool.endProfiling();341}342function isRunning(){343if(!__DEV__){344warnInProduction();345return false;346}347return ReactDebugTool.isProfiling();348}349var ReactPerfAnalysis={350getLastMeasurements:getLastMeasurements,351getExclusive:getExclusive,352getInclusive:getInclusive,353getWasted:getWasted,354getOperations:getOperations,355printExclusive:printExclusive,356printInclusive:printInclusive,357printWasted:printWasted,358printOperations:printOperations,...Using AI Code Generation
1I have tried to use the following code to import the file:2const { warnInProduction, logInProduction, debugInProduction, infoInProduction, errorInProduction, traceInProduction } = require('playwright/lib/utils/logger');3I have also tried to use the following code to import the file:4const { warnInProduction, logInProduction, debugInProduction, infoInProduction, errorInProduction, traceInProduction } = require('playwright/lib/utils/logger.js');5I have also tried to use the following code to import the file:6const { warnInProduction, logInProduction, debugInProduction, infoInProduction, errorInProduction, traceInProduction } = require('playwright/lib/utils/logger/index.js');7I have also tried to import the file using the following code:8const { warnInProduction, logInProduction, debugInProduction, infoInProduction, errorInProduction, traceInProduction } = require('playwright/lib/utils/logger/index');Using AI Code Generation
1const { warnInProduction } = require('@playwright/test/lib/utils/logger');2const { errorInProduction } = require('@playwright/test/lib/utils/logger');3const { debugInProduction } = require('@playwright/test/lib/utils/logger');4const { infoInProduction } = require('@playwright/test/lib/utils/logger');5const { logInProduction } = require('@playwright/test/lib/utils/logger');6const { printInProduction } = require('@playwright/test/lib/utils/logger');7const { clearInProduction } = require('@playwright/test/lib/utils/logger');Using AI Code Generation
1const { InternalError } = require('playwright/lib/internal/errors');2InternalError.warnInProduction('test', 'test');3InternalError.warnInProduction('test', 'test', 'test');4InternalError.warnInProduction('test', 'test', 'test', 'test');5InternalError.warnInProduction('test', 'test', 'test', 'test', 'test');6InternalError.warnInProduction('test', 'test', 'test', 'test', 'test', 'test');7InternalError.warnInProduction('test', 'test', 'test', 'test', 'test', 'test', 'test');8InternalError.warnInProduction('test', 'test', 'test', 'test', 'test', 'test', 'test', 'test');9const { TimeoutError } = require('playwright/lib/internal/errors');10TimeoutError.warnInProduction('test', 'test');11TimeoutError.warnInProduction('test', 'test', 'test');12TimeoutError.warnInProduction('test', 'test', 'test', 'test');13TimeoutError.warnInProduction('test', 'test', 'test', 'test', 'test');14TimeoutError.warnInProduction('test', 'test', 'test', 'test', 'test', 'test');15TimeoutError.warnInProduction('test', 'test', 'test', 'test', 'test', 'test', 'test');16TimeoutError.warnInProduction('test', 'test', 'test', 'test', 'test', 'test', 'test', 'test');17const { Error } = require('playwright/lib/internal/errors');18Error.warnInProduction('test', 'test');19Error.warnInProduction('test', 'test', 'test');20Error.warnInProduction('test', 'test', 'test', 'test');21Error.warnInProduction('test', 'test', 'test', 'test', 'test');22Error.warnInProduction('test', 'test', 'test', 'test', 'test', 'test');23Error.warnInProduction('test', 'test', 'test', 'test', 'test', 'test', 'test');24Error.warnInProduction('test', 'test', 'test', 'test', 'test', 'test', 'test', 'test');Using AI Code Generation
1const {InternalLogger} = require('@playwright/test/lib/utils/logger');2InternalLogger.warnInProduction('This is a warning');3const {InternalLogger} = require('@playwright/test/lib/utils/logger');4InternalLogger.setLogLevel('error');5InternalLogger.warnInProduction('This is a warning');6const {InternalLogger} = require('@playwright/test/lib/utils/logger');7InternalLogger.setLogLevel('error');8InternalLogger.warnInProduction('This is a warning');9const {InternalLogger} = require('@playwright/test/lib/utils/logger');10InternalLogger.setLogLevel('error');11InternalLogger.warnInProduction('This is a warning');12const {InternalLogger} = require('@playwright/test/lib/utils/logger');13InternalLogger.setLogLevel('error');14InternalLogger.warnInProduction('This is a warning');15const {InternalLogger} = require('@playwright/test/lib/utils/logger');16InternalLogger.setLogLevel('error');17InternalLogger.warnInProduction('This is a warning');18const {InternalLogger} = require('@playwright/test/lib/utils/logger');19InternalLogger.setLogLevel('error');20InternalLogger.warnInProduction('This is a warning');21const {InternalLogger} = require('@playwright/test/lib/utils/logger');22InternalLogger.setLogLevel('error');23InternalLogger.warnInProduction('This is a warning');24const {InternalLogger} = require('@playwright/test/lib/utils/logger');25InternalLogger.setLogLevel('error');26InternalLogger.warnInProduction('This is a warning');27const {InternalLogger} = require('@playwright/test/lib/utils/logger');28InternalLogger.setLogLevel('error');29InternalLogger.warnInProduction('This is a warning');30const {InternalLogger} = require('@playwright/test/lib/utils/logger');31InternalLogger.setLogLevel('error');32InternalLogger.warnInProduction('This is a warning');Using AI Code Generation
1const { warnInProduction } = require('playwright/lib/utils/utils');2warnInProduction('test warning');3const { test, expect } = require('@playwright/test');4test('warnInProduction', async ({ page }) => {5  const title = page.locator('.navbar__inner .navbar__title');6  await expect(title).toHaveText('Playwright');7});8const { setUnderTest } = require('playwright/lib/utils/utils');9setUnderTest();10const { test, expect } = require('@playwright/test');11test('setUnderTest', async ({ page }) => {12  const title = page.locator('.navbar__inner .navbar__title');13  await expect(title).toHaveText('Playwright');14});15const { setLogPrefix } = require('playwright/lib/utils/utils');16setLogPrefix('test');17const { test, expect } = require('@playwright/test');18test('setLogPrefix', async ({ page }) => {19  const title = page.locator('.navbar__inner .navbar__title');20  await expect(title).toHaveText('Playwright');21});22const {Using AI Code Generation
1const { Playwright } = require('@playwright/test');2const { warnInProduction } = Playwright.InternalLogger;3warnInProduction('test');4const { Playwright } = require('@playwright/test');5const { warn } = Playwright.InternalLogger;6warn('test');7const { Playwright } = require('@playwright/test');8const { warn } = Playwright.InternalLogger;9warn('test');Using AI Code Generation
1const { warnInProduction } = require('playwright-core/lib/utils/debug');2warnInProduction('This is a warning message');3console.log('This is a normal message');4const { debug } = require('playwright-core/lib/utils/debug');5debug('This is a debug message');6console.log('This is a normal message');7const { isDebugMode } = require('playwright-core/lib/utils/debug');8console.log(isDebugMode());9console.log('This is a normal message');10const { debugAssert } = require('playwright-core/lib/utils/debug');11debugAssert(true, 'This is a debug message');12debugAssert(false, 'This is a debug message');13console.log('This is a normal message');LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!
