Best JavaScript code snippet using playwright-internal
rpm.js
Source:rpm.js
...59 if (typeof console !== 'undefined') {60 console.error('ReactPerf is not supported in the production builds of React. ' + 'To collect measurements, please use the development build of React instead.');61 }62}63function getLastMeasurements() {64 if (!(process.env.NODE_ENV !== 'production')) {65 warnInProduction();66 return [];67 }68 return ReactDebugTool.getFlushHistory();69}70function getExclusive() {71 var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();72 if (!(process.env.NODE_ENV !== 'production')) {73 warnInProduction();74 return [];75 }76 var aggregatedStats = {};77 var affectedIDs = {};78 function updateAggregatedStats(treeSnapshot, instanceID, timerType, applyUpdate) {79 var displayName = treeSnapshot[instanceID].displayName;80 var key = displayName;81 var stats = aggregatedStats[key];82 if (!stats) {83 affectedIDs[key] = {};84 stats = aggregatedStats[key] = {85 key: key,86 instanceCount: 0,87 counts: {},88 durations: {},89 totalDuration: 090 };91 }92 if (!stats.durations[timerType]) {93 stats.durations[timerType] = 0;94 }95 if (!stats.counts[timerType]) {96 stats.counts[timerType] = 0;97 }98 affectedIDs[key][instanceID] = true;99 applyUpdate(stats);100 }101 flushHistory.forEach(function (flush) {102 var measurements = flush.measurements,103 treeSnapshot = flush.treeSnapshot;104 measurements.forEach(function (measurement) {105 var duration = measurement.duration,106 instanceID = measurement.instanceID,107 timerType = measurement.timerType;108 updateAggregatedStats(treeSnapshot, instanceID, timerType, function (stats) {109 stats.totalDuration += duration;110 stats.durations[timerType] += duration;111 stats.counts[timerType]++;112 });113 });114 });115 return Object.keys(aggregatedStats).map(function (key) {116 return _extends({}, aggregatedStats[key], {117 instanceCount: Object.keys(affectedIDs[key]).length118 });119 }).sort(function (a, b) {120 return b.totalDuration - a.totalDuration;121 });122}123function getInclusive() {124 var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();125 if (!(process.env.NODE_ENV !== 'production')) {126 warnInProduction();127 return [];128 }129 var aggregatedStats = {};130 var affectedIDs = {};131 function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {132 var _treeSnapshot$instanc = treeSnapshot[instanceID],133 displayName = _treeSnapshot$instanc.displayName,134 ownerID = _treeSnapshot$instanc.ownerID;135 var owner = treeSnapshot[ownerID];136 var key = (owner ? owner.displayName + ' > ' : '') + displayName;137 var stats = aggregatedStats[key];138 if (!stats) {139 affectedIDs[key] = {};140 stats = aggregatedStats[key] = {141 key: key,142 instanceCount: 0,143 inclusiveRenderDuration: 0,144 renderCount: 0145 };146 }147 affectedIDs[key][instanceID] = true;148 applyUpdate(stats);149 }150 var isCompositeByID = {};151 flushHistory.forEach(function (flush) {152 var measurements = flush.measurements;153 measurements.forEach(function (measurement) {154 var instanceID = measurement.instanceID,155 timerType = measurement.timerType;156 if (timerType !== 'render') {157 return;158 }159 isCompositeByID[instanceID] = true;160 });161 });162 flushHistory.forEach(function (flush) {163 var measurements = flush.measurements,164 treeSnapshot = flush.treeSnapshot;165 measurements.forEach(function (measurement) {166 var duration = measurement.duration,167 instanceID = measurement.instanceID,168 timerType = measurement.timerType;169 if (timerType !== 'render') {170 return;171 }172 updateAggregatedStats(treeSnapshot, instanceID, function (stats) {173 stats.renderCount++;174 });175 var nextParentID = instanceID;176 while (nextParentID) {177 // As we traverse parents, only count inclusive time towards composites.178 // We know something is a composite if its render() was called.179 if (isCompositeByID[nextParentID]) {180 updateAggregatedStats(treeSnapshot, nextParentID, function (stats) {181 stats.inclusiveRenderDuration += duration;182 });183 }184 nextParentID = treeSnapshot[nextParentID].parentID;185 }186 });187 });188 return Object.keys(aggregatedStats).map(function (key) {189 return _extends({}, aggregatedStats[key], {190 instanceCount: Object.keys(affectedIDs[key]).length191 });192 }).sort(function (a, b) {193 return b.inclusiveRenderDuration - a.inclusiveRenderDuration;194 });195}196function getWasted() {197 var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();198 if (!(process.env.NODE_ENV !== 'production')) {199 warnInProduction();200 return [];201 }202 var aggregatedStats = {};203 var affectedIDs = {};204 function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {205 var _treeSnapshot$instanc2 = treeSnapshot[instanceID],206 displayName = _treeSnapshot$instanc2.displayName,207 ownerID = _treeSnapshot$instanc2.ownerID;208 var owner = treeSnapshot[ownerID];209 var key = (owner ? owner.displayName + ' > ' : '') + displayName;210 var stats = aggregatedStats[key];211 if (!stats) {212 affectedIDs[key] = {};213 stats = aggregatedStats[key] = {214 key: key,215 instanceCount: 0,216 inclusiveRenderDuration: 0,217 renderCount: 0218 };219 }220 affectedIDs[key][instanceID] = true;221 applyUpdate(stats);222 }223 flushHistory.forEach(function (flush) {224 var measurements = flush.measurements,225 treeSnapshot = flush.treeSnapshot,226 operations = flush.operations;227 var isDefinitelyNotWastedByID = {};228 // Find host components associated with an operation in this batch.229 // Mark all components in their parent tree as definitely not wasted.230 operations.forEach(function (operation) {231 var instanceID = operation.instanceID;232 var nextParentID = instanceID;233 while (nextParentID) {234 isDefinitelyNotWastedByID[nextParentID] = true;235 nextParentID = treeSnapshot[nextParentID].parentID;236 }237 });238 // Find composite components that rendered in this batch.239 // These are potential candidates for being wasted renders.240 var renderedCompositeIDs = {};241 measurements.forEach(function (measurement) {242 var instanceID = measurement.instanceID,243 timerType = measurement.timerType;244 if (timerType !== 'render') {245 return;246 }247 renderedCompositeIDs[instanceID] = true;248 });249 measurements.forEach(function (measurement) {250 var duration = measurement.duration,251 instanceID = measurement.instanceID,252 timerType = measurement.timerType;253 if (timerType !== 'render') {254 return;255 }256 // If there was a DOM update below this component, or it has just been257 // mounted, its render() is not considered wasted.258 var updateCount = treeSnapshot[instanceID].updateCount;259 if (isDefinitelyNotWastedByID[instanceID] || updateCount === 0) {260 return;261 }262 // We consider this render() wasted.263 updateAggregatedStats(treeSnapshot, instanceID, function (stats) {264 stats.renderCount++;265 });266 var nextParentID = instanceID;267 while (nextParentID) {268 // Any parents rendered during this batch are considered wasted269 // unless we previously marked them as dirty.270 var isWasted = renderedCompositeIDs[nextParentID] && !isDefinitelyNotWastedByID[nextParentID];271 if (isWasted) {272 updateAggregatedStats(treeSnapshot, nextParentID, function (stats) {273 stats.inclusiveRenderDuration += duration;274 });275 }276 nextParentID = treeSnapshot[nextParentID].parentID;277 }278 });279 });280 return Object.keys(aggregatedStats).map(function (key) {281 return _extends({}, aggregatedStats[key], {282 instanceCount: Object.keys(affectedIDs[key]).length283 });284 }).sort(function (a, b) {285 return b.inclusiveRenderDuration - a.inclusiveRenderDuration;286 });287}288function getOperations() {289 var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();290 if (!(process.env.NODE_ENV !== 'production')) {291 warnInProduction();292 return [];293 }294 var stats = [];295 flushHistory.forEach(function (flush, flushIndex) {296 var operations = flush.operations,297 treeSnapshot = flush.treeSnapshot;298 operations.forEach(function (operation) {299 var instanceID = operation.instanceID,300 type = operation.type,301 payload = operation.payload;302 var _treeSnapshot$instanc3 = treeSnapshot[instanceID],303 displayName = _treeSnapshot$instanc3.displayName,...
ReactPerf.js
Source:ReactPerf.js
...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,...
6b8a09e6ac23b036fdcd9bbaded5e50e7a430eReactPerf.js
Source:6b8a09e6ac23b036fdcd9bbaded5e50e7a430eReactPerf.js
...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,...
16edb4adaa753cbcca816d5dd5f0bc041a1046ReactPerf.js
Source:16edb4adaa753cbcca816d5dd5f0bc041a1046ReactPerf.js
...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,...
e3040dReactPerf.js
Source:e3040dReactPerf.js
...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,...
711832ReactPerf.js
Source:711832ReactPerf.js
...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,...
6558d0ReactPerf.js
Source:6558d0ReactPerf.js
...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,...
index.js
Source:index.js
...11 started ? Perf.stop() : Perf.start();12 this.setState({ started: !started });13 }14 printWasted = () => {15 const lastMeasurements = Perf.getLastMeasurements();16 Perf.printWasted(lastMeasurements);17 }18 printOperations = () => {19 const lastMeasurements = Perf.getLastMeasurements();20 Perf.printOperations(lastMeasurements);21 }22 render() {23 const { started } = this.state;24 return <div className="perf-profiler">25 <h1>Performance Profiler</h1>26 <button onClick={this.toggle}>{started ? 'Stop' : 'Start'}</button>27 <button onClick={this.printWasted}>Print Wasted</button>28 <button onClick={this.printOperations}>Print Operations</button>29 </div>;30 }31}...
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 const metrics = await page._delegate.getLastMeasurements();6 console.log(metrics);7 await browser.close();8})();9{10}
Using AI Code Generation
1const { getLastMeasurements } = require('playwright/lib/server/chromium/crNetworkRecorder');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const measurements = getLastMeasurements(page);8 console.log(measurements);9 await browser.close();10})();11{ navigationStart: 0,12 estimatedInputLatency: 0 }13const { chromium } = require('playwright');14const { getLastMeasurements } = require('playwright/lib/server/chromium/crNetworkRecorder');15(async () => {16 const browser = await chromium.launch();17 const context = await browser.newContext();18 const page = await context.newPage();19 const measurements = getLastMeasurements(page);20 console.log(measurements);21 await browser.close();22})();
Using AI Code Generation
1const { getLastMeasurements } = require('@playwright/test/lib/traceViewer/traceModel');2const { getNetworkEvents } = require('@playwright/test/lib/traceViewer/networkModel');3const { getFrames } = require('@playwright/test/lib/traceViewer/frameModel');4const { getFrameTree } = require('@playwright/test/lib/traceViewer/frameTree');5const { chromium } = require('playwright');6const fs = require('fs');7const path = require('path');8(async () => {9 const browser = await chromium.launch({ headless: false });10 const context = await browser.newContext();11 const page = await context.newPage();12 await page.screenshot({ path: 'example.png' });13 const trace = await page.context().tracing.stop({ screenshots: true, snapshots: true });14 fs.writeFileSync(path.join(__dirname, 'trace.zip'), trace);15 await browser.close();16})();17const { chromium } = require('playwright');18const fs = require('fs');19const path = require('path');20const trace = fs.readFileSync(path.join(__dirname, 'trace.zip'));21const traceViewer = await chromium.loadTrace(trace);22const { getLastMeasurements } = require('@playwright/test/lib/traceViewer/traceModel');23const { getNetworkEvents } = require('@playwright/test/lib/traceViewer/networkModel');24const { getFrames } = require('@playwright/test/lib/traceViewer/frameModel');25const { getFrameTree } = require('@playwright/test/lib/traceViewer/frameTree');26const measurements = getLastMeasurements(traceViewer);27const networkEvents = getNetworkEvents(traceViewer);28const frames = getFrames(traceViewer);29const frameTree = getFrameTree(traceViewer);30console.log(measurements);31console.log(networkEvents);32console.log(frames);33console.log(frameTree);
Using AI Code Generation
1const { getLastMeasurements } = require('playwright/lib/server/trace/recorder/recorderApp');2const measurements = await getLastMeasurements();3console.log(measurements);4const { getLastMeasurements } = require('playwright/lib/server/trace/recorder/recorderApp');5const measurements = await getLastMeasurements();6console.log(measurements);7const { getLastMeasurements } = require('playwright/lib/server/trace/recorder/recorderApp');8const measurements = await getLastMeasurements();9console.log(measurements);10const { getLastMeasurements } = require('playwright/lib/server/trace/recorder/recorderApp');11const measurements = await getLastMeasurements();12console.log(measurements);13const { getLastMeasurements } = require('playwright/lib/server/trace/recorder/recorderApp');14const measurements = await getLastMeasurements();15console.log(measurements);16const { getLastMeasurements } = require('playwright/lib/server/trace/recorder/recorderApp');17const measurements = await getLastMeasurements();18console.log(measurements);19const { getLastMeasurements } = require('playwright/lib/server/trace/recorder/recorderApp');20const measurements = await getLastMeasurements();21console.log(measurements);22const { getLastMeasurements } = require('playwright/lib/server/trace/recorder/recorderApp');23const measurements = await getLastMeasurements();24console.log(measurements);25const { getLastMeasurements } = require('playwright/lib/server/trace/recorder/recorderApp');26const measurements = await getLastMeasurements();27console.log(measurements);28const { getLastMeasurements } = require('playwright/lib/server/trace/recorder/recorderApp');29const measurements = await getLastMeasurements();30console.log(measurements);31const { getLastMeasurements } =
Using AI Code Generation
1const { getLastMeasurements } = require('@playwright/test/lib/server/traceViewer/traceModel');2const trace = require('./trace.json');3const { performance } = require('perf_hooks');4const t0 = performance.now();5const lastMeasurements = getLastMeasurements(trace.traceEvents);6const t1 = performance.now();7console.log(`Performance: ${t1 - t0} ms`);8console.log(lastMeasurements);9{10 }11}12const { getLastMeasurements } = require('@playwright/test/lib/server/traceViewer/traceModel');13const trace = require('./trace.json');14const { performance } = require('perf_hooks');15const t0 = performance.now();16const lastMeasurements = getLastMeasurements(trace.traceEvents);17const t1 = performance.now();18console.log(`Performance: ${t1 - t0} ms`);19console.log(lastMeasurements);20Contributions are welcome! Please check out the [Contributing to Playwright](
Using AI Code Generation
1const { getLastMeasurements } = require('@playwright/test/lib/server/traceViewer/traceModel');2const { chromium } = require('playwright');3const trace = require('./trace.json');4const traceModel = getLastMeasurements(trace);5const { page } = await chromium.launch({ trace: 'trace.zip' });6await page.screenshot({ path: 'example.png' });7await page.close();8await browser.close();9const { page } = await chromium.launch({ trace: 'trace.zip' });10const trace = require('./trace.json');11const traceModel = getLastMeasurements(trace);12const { page } = await chromium.launch({ trace: 'trace.zip' });13await page.screenshot({ path: 'example.png' });14await page.close();15await browser.close();16const { page } = await chromium.launch({ trace: 'trace.zip' });17const trace = require('./trace.json');18const traceModel = getLastMeasurements(trace);19const { page } = await chromium.launch({ trace: 'trace.zip' });20const trace = require('./trace.json');21const traceModel = getLastMeasurements(trace);22const { page } = await chromium.launch({ trace: 'trace.zip' });23const trace = require('./trace.json');24const traceModel = getLastMeasurements(trace);25const { page } = await chromium.launch({ trace: 'trace.zip' });26const trace = require('./trace.json');27const traceModel = getLastMeasurements(trace);28const { page } = await chromium.launch({ trace: 'trace.zip' });29const trace = require('./trace.json');30const traceModel = getLastMeasurements(trace);31const { page } = await chromium.launch({ trace: 'trace.zip' });32const trace = require('./trace.json');33const traceModel = getLastMeasurements(trace);34const { page } = await chromium.launch({ trace: 'trace.zip' });35const trace = require('./trace.json');36const traceModel = getLastMeasurements(trace);37const { page } = await chromium.launch({ trace: 'trace.zip' });38const trace = require('./trace.json');
Using AI Code Generation
1const { getLastMeasurements } = require('@playwright/test/lib/trace/recorder/measurements');2const measurements = getLastMeasurements();3console.log(measurements);4const { getLastMeasurements } = require('@playwright/test/lib/trace/recorder/measurements');5const measurements = getLastMeasurements();6console.log(measurements);
Using AI Code Generation
1const { getLastMeasurements } = require('@playwright/test/lib/traceModel');2const trace = await getLastMeasurements();3console.log(trace);4await browser.close();5{ 'recording-1': { 'action-1': { 'measure-1': { start: 0, end: 0.4 } } } }6{ 'recording-id': { 'action-id': { 'measure-id': { start: 0, end: 0.4 } } } }
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!!