Best JavaScript code snippet using playwright-internal
ReactPerf.js
Source: ReactPerf.js
...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 });...
b27cd6ReactPerf.js
Source: b27cd6ReactPerf.js
...34 return [];35 }36 var aggregatedStats = {};37 var affectedIDs = {};38 function updateAggregatedStats(treeSnapshot, instanceID, timerType, applyUpdate) {39 var displayName = treeSnapshot[instanceID].displayName;40 var key = displayName;41 var stats = aggregatedStats[key];42 if (!stats) {43 affectedIDs[key] = {};44 stats = aggregatedStats[key] = {45 key: key,46 instanceCount: 0,47 counts: {},48 durations: {},49 totalDuration: 050 };51 }52 if (!stats.durations[timerType]) {53 stats.durations[timerType] = 0;54 }55 if (!stats.counts[timerType]) {56 stats.counts[timerType] = 0;57 }58 affectedIDs[key][instanceID] = true;59 applyUpdate(stats);60 }61 flushHistory.forEach(function (flush) {62 var measurements = flush.measurements,63 treeSnapshot = flush.treeSnapshot;64 measurements.forEach(function (measurement) {65 var duration = measurement.duration,66 instanceID = measurement.instanceID,67 timerType = measurement.timerType;68 updateAggregatedStats(treeSnapshot, instanceID, timerType, function (stats) {69 stats.totalDuration += duration;70 stats.durations[timerType] += duration;71 stats.counts[timerType]++;72 });73 });74 });75 return Object.keys(aggregatedStats).map(function (key) {76 return _extends({}, aggregatedStats[key], {77 instanceCount: Object.keys(affectedIDs[key]).length78 });79 }).sort(function (a, b) {80 return b.totalDuration - a.totalDuration;81 });82}83function getInclusive() {84 var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();85 if (!__DEV__) {86 warnInProduction();87 return [];88 }89 var aggregatedStats = {};90 var affectedIDs = {};91 function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {92 var _treeSnapshot$instanc = treeSnapshot[instanceID],93 displayName = _treeSnapshot$instanc.displayName,94 ownerID = _treeSnapshot$instanc.ownerID;95 var owner = treeSnapshot[ownerID];96 var key = (owner ? owner.displayName + ' > ' : '') + displayName;97 var stats = aggregatedStats[key];98 if (!stats) {99 affectedIDs[key] = {};100 stats = aggregatedStats[key] = {101 key: key,102 instanceCount: 0,103 inclusiveRenderDuration: 0,104 renderCount: 0105 };106 }107 affectedIDs[key][instanceID] = true;108 applyUpdate(stats);109 }110 var isCompositeByID = {};111 flushHistory.forEach(function (flush) {112 var measurements = flush.measurements;113 measurements.forEach(function (measurement) {114 var instanceID = measurement.instanceID,115 timerType = measurement.timerType;116 if (timerType !== 'render') {117 return;118 }119 isCompositeByID[instanceID] = true;120 });121 });122 flushHistory.forEach(function (flush) {123 var measurements = flush.measurements,124 treeSnapshot = flush.treeSnapshot;125 measurements.forEach(function (measurement) {126 var duration = measurement.duration,127 instanceID = measurement.instanceID,128 timerType = measurement.timerType;129 if (timerType !== 'render') {130 return;131 }132 updateAggregatedStats(treeSnapshot, instanceID, function (stats) {133 stats.renderCount++;134 });135 var nextParentID = instanceID;136 while (nextParentID) {137 if (isCompositeByID[nextParentID]) {138 updateAggregatedStats(treeSnapshot, nextParentID, function (stats) {139 stats.inclusiveRenderDuration += duration;140 });141 }142 nextParentID = treeSnapshot[nextParentID].parentID;143 }144 });145 });146 return Object.keys(aggregatedStats).map(function (key) {147 return _extends({}, aggregatedStats[key], {148 instanceCount: Object.keys(affectedIDs[key]).length149 });150 }).sort(function (a, b) {151 return b.inclusiveRenderDuration - a.inclusiveRenderDuration;152 });153}154function getWasted() {155 var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();156 if (!__DEV__) {157 warnInProduction();158 return [];159 }160 var aggregatedStats = {};161 var affectedIDs = {};162 function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {163 var _treeSnapshot$instanc2 = treeSnapshot[instanceID],164 displayName = _treeSnapshot$instanc2.displayName,165 ownerID = _treeSnapshot$instanc2.ownerID;166 var owner = treeSnapshot[ownerID];167 var key = (owner ? owner.displayName + ' > ' : '') + displayName;168 var stats = aggregatedStats[key];169 if (!stats) {170 affectedIDs[key] = {};171 stats = aggregatedStats[key] = {172 key: key,173 instanceCount: 0,174 inclusiveRenderDuration: 0,175 renderCount: 0176 };177 }178 affectedIDs[key][instanceID] = true;179 applyUpdate(stats);180 }181 flushHistory.forEach(function (flush) {182 var measurements = flush.measurements,183 treeSnapshot = flush.treeSnapshot,184 operations = flush.operations;185 var isDefinitelyNotWastedByID = {};186 operations.forEach(function (operation) {187 var instanceID = operation.instanceID;188 var nextParentID = instanceID;189 while (nextParentID) {190 isDefinitelyNotWastedByID[nextParentID] = true;191 nextParentID = treeSnapshot[nextParentID].parentID;192 }193 });194 var renderedCompositeIDs = {};195 measurements.forEach(function (measurement) {196 var instanceID = measurement.instanceID,197 timerType = measurement.timerType;198 if (timerType !== 'render') {199 return;200 }201 renderedCompositeIDs[instanceID] = true;202 });203 measurements.forEach(function (measurement) {204 var duration = measurement.duration,205 instanceID = measurement.instanceID,206 timerType = measurement.timerType;207 if (timerType !== 'render') {208 return;209 }210 var updateCount = treeSnapshot[instanceID].updateCount;211 if (isDefinitelyNotWastedByID[instanceID] || updateCount === 0) {212 return;213 }214 updateAggregatedStats(treeSnapshot, instanceID, function (stats) {215 stats.renderCount++;216 });217 var nextParentID = instanceID;218 while (nextParentID) {219 var isWasted = renderedCompositeIDs[nextParentID] && !isDefinitelyNotWastedByID[nextParentID];220 if (isWasted) {221 updateAggregatedStats(treeSnapshot, nextParentID, function (stats) {222 stats.inclusiveRenderDuration += duration;223 });224 }225 nextParentID = treeSnapshot[nextParentID].parentID;226 }227 });228 });229 return Object.keys(aggregatedStats).map(function (key) {230 return _extends({}, aggregatedStats[key], {231 instanceCount: Object.keys(affectedIDs[key]).length232 });233 }).sort(function (a, b) {234 return b.inclusiveRenderDuration - a.inclusiveRenderDuration;235 });...
68efb5ReactPerf.js
Source: 68efb5ReactPerf.js
...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 });...
1e0976ReactPerf.js
Source: 1e0976ReactPerf.js
...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 });...
d3c64eReactPerf.js
Source: d3c64eReactPerf.js
...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 });...
3fd3f73792aa58b1edf5fe0f55d024146afb28ReactPerf.js
...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 });...
9d2366ReactPerf.js
Source: 9d2366ReactPerf.js
...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}...
v2.js
Source: v2.js
1/**2 * Copyright 2014 Google Inc. All Rights Reserved.3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16/* jshint maxlen: false */17'use strict';18var createAPIRequest = require('../../lib/apirequest');19/**20 * Google Cloud Network Performance Monitoring API21 *22 * @classdesc A Test API to report latency data.23 * @namespace cloudlatencytest24 * @version v225 * @variation v226 * @this Cloudlatencytest27 * @param {object=} options Options for Cloudlatencytest28 */29function Cloudlatencytest(options) {30 var self = this;31 this._options = options || {};32 this.statscollection = {33 /**34 * cloudlatencytest.statscollection.updateaggregatedstats35 *36 * @desc RPC to update the new TCP stats.37 *38 * @alias cloudlatencytest.statscollection.updateaggregatedstats39 * @memberOf! cloudlatencytest(v2)40 *41 * @param {object} params - Parameters for request42 * @param {object} params.resource - Request body data43 * @param {callback} callback - The callback that handles the response.44 * @return {object} Request object45 */46 updateaggregatedstats: function(params, callback) {47 var parameters = {48 options: {49 url: 'https://cloudlatencytest-pa.googleapis.com/v2/statscollection/updateaggregatedstats',50 method: 'POST'51 },52 params: params,53 requiredParams: [],54 pathParams: [],55 context: self56 };57 return createAPIRequest(parameters, callback);58 },59 /**60 * cloudlatencytest.statscollection.updatestats61 *62 * @desc RPC to update the new TCP stats.63 *64 * @alias cloudlatencytest.statscollection.updatestats65 * @memberOf! cloudlatencytest(v2)66 *67 * @param {object} params - Parameters for request68 * @param {object} params.resource - Request body data69 * @param {callback} callback - The callback that handles the response.70 * @return {object} Request object71 */72 updatestats: function(params, callback) {73 var parameters = {74 options: {75 url: 'https://cloudlatencytest-pa.googleapis.com/v2/statscollection/updatestats',76 method: 'POST'77 },78 params: params,79 requiredParams: [],80 pathParams: [],81 context: self82 };83 return createAPIRequest(parameters, callback);84 }85 };86}87/**88 * Exports Cloudlatencytest object89 * @type Cloudlatencytest90 */...
Using AI Code Generation
1const { chromium } = require('playwright');2const { updateAggregatedStats } = require('playwright/lib/utils/stats');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await updateAggregatedStats(page, 'metric', 10);8 await updateAggregatedStats(page, 'metric', 20);9 const result = await page.evaluate(() => window.__playwright__testStats);10 console.log(result);11 await browser.close();12})();13### [BrowserContext] method: BrowserContext.overridePermissions(origin, permissions)14const { chromium } = require('playwright');15(async () => {16 const browser = await chromium.launch();17 const context = await browser.newContext();18 const page = await context.newPage();19 await page.click('text=Ask for Permission');20 await page.waitForSelector('text=Permission Granted');21 await browser.close();22})();23### [BrowserContext] method: BrowserContext.setGeolocation(options)24const { chromium } = require('playwright');25(async () => {26 const browser = await chromium.launch();27 const context = await browser.newContext();28 await context.setGeolocation({latitude: 59.95, longitude: 30.31667});29 const page = await context.newPage();30 await page.waitForSelector('text=Your location');31 await browser.close();32})();
Using AI Code Generation
1const playwright = require('playwright');2const { updateAggregatedStats } = require('playwright/lib/utils/stats');3(async () => {4 const browser = await playwright.chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.screenshot({ path: 'example.png' });8 await browser.close();9 const stats = await updateAggregatedStats();10 console.log(stats);11})();
Using AI Code Generation
1const { chromium } = require('playwright');2const { updateAggregatedStats } = require('playwright/lib/server/trace/recorder/recorderApp');3const browser = await chromium.launch();4const context = await browser.newContext();5const page = await context.newPage();6await updateAggregatedStats('test', page);7await browser.close();8const { updateAggregatedStats } = require('playwright/lib/server/trace/recorder/recorderApp');9const { chromium } = require('playwright');10const browser = await chromium.launch();11const context = await browser.newContext();12const page = await context.newPage();13await updateAggregatedStats('test', page);14await browser.close();
Using AI Code Generation
1const { updateAggregatedStats } = require('playwright-core/lib/server/trace/viewer/traceModel');2const { TraceModel } = require('playwright-core/lib/server/trace/viewer/traceModel');3const { TraceViewer } = require('playwright-core/lib/server/trace/viewer/traceViewer');4const { TraceProcessor } = require('playwright-core/lib/server/trace/viewer/traceProcessor');5const { TimelineModel } = require('playwright-core/lib/server/trace/viewer/timelineModel');6const model = new TraceModel();7const viewer = new TraceViewer();8const processor = new TraceProcessor();9const timelineModel = new TimelineModel(processor);10const traceCategories = ['devtools.timeline', 'v8.execute', 'disabled-by-default-devtools.timeline', 'disabled-by-default-devtools.timeline.frame', 'toplevel', 'blink.console', 'disabled-by-default-devtools.screenshot', 'disabled-by-default-devtools.timeline.stack', 'disabled-by-default-v8.cpu_profiler', 'disabled-by-default-v8.cpu_profiler.hires'];11const events = require('./events.json');12const trace = {traceEvents: events};13model.setEvents(trace.traceEvents);14timelineModel.setEvents(model, traceCategories);15const stats = timelineModel.aggregatedStats();16const statsToUpdate = {17 'Layout': {18 }19};20updateAggregatedStats(timelineModel, statsToUpdate);21console.log(timelineModel.aggregatedStats());22{
Using AI Code Generation
1const { updateAggregatedStats } = require('playwright/lib/test/reporter');2const { test } = require('@playwright/test');3test('my test', async ({ page }) => {4 updateAggregatedStats({5 });6});
Using AI Code Generation
1const { updateAggregatedStats } = require('@playwright/test/lib/runner');2const { test } = require('@playwright/test');3test.describe('My Test', () => {4 test.beforeEach(async ({}, testInfo) => {5 updateAggregatedStats(testInfo, { status: 'skipped' });6 });7 test('My Test', async ({}, testInfo) => {8 });9});
Using AI Code Generation
1const playwright_internal = require('playwright-internal');2const playwright = new playwright_internal.Playwright();3const browserType = playwright.chromium;4const browser = await browserType.launch();5const page = await browser.newPage();6await page.updateAggregatedStats();7await browser.close();8await playwright.close();9const playwright_internal = require('playwright-internal');10const playwright = new playwright_internal.Playwright();11const browserType = playwright.chromium;12const browser = await browserType.launch();13const context = await browser.newContext();14const page = await context.newPage();15await page.setContext(context);16await browser.close();17await playwright.close();18const playwright_internal = require('playwright-internal');19const playwright = new playwright_internal.Playwright();20const browserType = playwright.chromium;21const browser = await browserType.launch();22const page = await browser.newPage();
Using AI Code Generation
1const { updateAggregatedStats } = require('@playwright/test');2updateAggregatedStats('test.js', {3 test: { passed: 1 },4 suite: { passed: 1 },5 worker: { passed: 1 },6});7const { updateAggregatedStats } = require('@playwright/test');8updateAggregatedStats('test2.js', {9 test: { failed: 1 },10 suite: { failed: 1 },11 worker: { failed: 1 },12});13const { updateAggregatedStats } = require('@playwright/test');14updateAggregatedStats('test3.js', {15 test: { skipped: 1 },16 suite: { skipped: 1 },17 worker: { skipped: 1 },18});19const { updateAggregatedStats } = require('@playwright/test');20updateAggregatedStats('test4.js', {21 test: { failed: 1, passed: 1 },22 suite: { failed: 1, passed: 1 },23 worker: { failed: 1, passed: 1 },24});25const { updateAggregatedStats } = require('@playwright/test');26updateAggregatedStats('test5.js', {27 test: { failed: 1, skipped: 1 },28 suite: { failed: 1, skipped: 1 },29 worker: { failed: 1, skipped: 1 },30});
Jest + Playwright - Test callbacks of event-based DOM library
firefox browser does not start in playwright
Is it possible to get the selector from a locator object in playwright?
How to run a list of test suites in a single file concurrently in jest?
Running Playwright in Azure Function
firefox browser does not start in playwright
This question is quite close to a "need more focus" question. But let's try to give it some focus:
Does Playwright has access to the cPicker object on the page? Does it has access to the window object?
Yes, you can access both cPicker and the window object inside an evaluate call.
Should I trigger the events from the HTML file itself, and in the callbacks, print in the DOM the result, in some dummy-element, and then infer from that dummy element text that the callbacks fired?
Exactly, or you can assign values to a javascript variable:
const cPicker = new ColorPicker({
onClickOutside(e){
},
onInput(color){
window['color'] = color;
},
onChange(color){
window['result'] = color;
}
})
And then
it('Should call all callbacks with correct arguments', async() => {
await page.goto(`http://localhost:5000/tests/visual/basic.html`, {waitUntil:'load'})
// Wait until the next frame
await page.evaluate(() => new Promise(requestAnimationFrame))
// Act
// Assert
const result = await page.evaluate(() => window['color']);
// Check the value
})
Check out the latest blogs from LambdaTest on this topic:
Native apps are developed specifically for one platform. Hence they are fast and deliver superior performance. They can be downloaded from various app stores and are not accessible through browsers.
One of the essential parts when performing automated UI testing, whether using Selenium or another framework, is identifying the correct web elements the tests will interact with. However, if the web elements are not located correctly, you might get NoSuchElementException in Selenium. This would cause a false negative result because we won’t get to the actual functionality check. Instead, our test will fail simply because it failed to interact with the correct element.
Smartphones have changed the way humans interact with technology. Be it travel, fitness, lifestyle, video games, or even services, it’s all just a few touches away (quite literally so). We only need to look at the growing throngs of smartphone or tablet users vs. desktop users to grasp this reality.
As part of one of my consulting efforts, I worked with a mid-sized company that was looking to move toward a more agile manner of developing software. As with any shift in work style, there is some bewilderment and, for some, considerable anxiety. People are being challenged to leave their comfort zones and embrace a continuously changing, dynamic working environment. And, dare I say it, testing may be the most ‘disturbed’ of the software roles in agile development.
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!!