How to use resetMeasurements method in Playwright Internal

Best JavaScript code snippet using playwright-internal

25935eReactDebugTool.js

Source:25935eReactDebugTool.js Github

copy

Full Screen

...55 };56 return tree;57 }, {});58 };59 var resetMeasurements = function resetMeasurements() {60 var previousStartTime = currentFlushStartTime;61 var previousMeasurements = currentFlushMeasurements;62 var previousOperations = ReactHostOperationHistoryHook.getHistory();63 if (currentFlushNesting === 0) {64 currentFlushStartTime = 0;65 currentFlushMeasurements = [];66 clearHistory();67 return;68 }69 if (previousMeasurements.length || previousOperations.length) {70 var registeredIDs = ReactComponentTreeHook.getRegisteredIDs();71 flushHistory.push({72 duration: performanceNow() - previousStartTime,73 measurements: previousMeasurements || [],74 operations: previousOperations || [],75 treeSnapshot: getTreeSnapshot(registeredIDs)76 });77 }78 clearHistory();79 currentFlushStartTime = performanceNow();80 currentFlushMeasurements = [];81 };82 var checkDebugID = function checkDebugID(debugID) {83 var allowRoot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;84 if (allowRoot && debugID === 0) {85 return;86 }87 if (!debugID) {88 warning(false, 'ReactDebugTool: debugID may not be empty.');89 }90 };91 var beginLifeCycleTimer = function beginLifeCycleTimer(debugID, timerType) {92 if (currentFlushNesting === 0) {93 return;94 }95 if (currentTimerType && !lifeCycleTimerHasWarned) {96 warning(false, 'There is an internal error in the React performance measurement code.' + '\n\nDid not expect %s timer to start while %s timer is still in ' + 'progress for %s instance.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another');97 lifeCycleTimerHasWarned = true;98 }99 currentTimerStartTime = performanceNow();100 currentTimerNestedFlushDuration = 0;101 currentTimerDebugID = debugID;102 currentTimerType = timerType;103 };104 var endLifeCycleTimer = function endLifeCycleTimer(debugID, timerType) {105 if (currentFlushNesting === 0) {106 return;107 }108 if (currentTimerType !== timerType && !lifeCycleTimerHasWarned) {109 warning(false, 'There is an internal error in the React performance measurement code. ' + 'We did not expect %s timer to stop while %s timer is still in ' + 'progress for %s instance. Please report this as a bug in React.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another');110 lifeCycleTimerHasWarned = true;111 }112 if (_isProfiling) {113 currentFlushMeasurements.push({114 timerType: timerType,115 instanceID: debugID,116 duration: performanceNow() - currentTimerStartTime - currentTimerNestedFlushDuration117 });118 }119 currentTimerStartTime = 0;120 currentTimerNestedFlushDuration = 0;121 currentTimerDebugID = null;122 currentTimerType = null;123 };124 var pauseCurrentLifeCycleTimer = function pauseCurrentLifeCycleTimer() {125 var currentTimer = {126 startTime: currentTimerStartTime,127 nestedFlushStartTime: performanceNow(),128 debugID: currentTimerDebugID,129 timerType: currentTimerType130 };131 lifeCycleTimerStack.push(currentTimer);132 currentTimerStartTime = 0;133 currentTimerNestedFlushDuration = 0;134 currentTimerDebugID = null;135 currentTimerType = null;136 };137 var resumeCurrentLifeCycleTimer = function resumeCurrentLifeCycleTimer() {138 var _lifeCycleTimerStack$ = lifeCycleTimerStack.pop(),139 startTime = _lifeCycleTimerStack$.startTime,140 nestedFlushStartTime = _lifeCycleTimerStack$.nestedFlushStartTime,141 debugID = _lifeCycleTimerStack$.debugID,142 timerType = _lifeCycleTimerStack$.timerType;143 var nestedFlushDuration = performanceNow() - nestedFlushStartTime;144 currentTimerStartTime = startTime;145 currentTimerNestedFlushDuration += nestedFlushDuration;146 currentTimerDebugID = debugID;147 currentTimerType = timerType;148 };149 var lastMarkTimeStamp = 0;150 var canUsePerformanceMeasure = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function';151 var shouldMark = function shouldMark(debugID) {152 if (!_isProfiling || !canUsePerformanceMeasure) {153 return false;154 }155 var element = ReactComponentTreeHook.getElement(debugID);156 if (element == null || typeof element !== 'object') {157 return false;158 }159 var isHostElement = typeof element.type === 'string';160 if (isHostElement) {161 return false;162 }163 return true;164 };165 var markBegin = function markBegin(debugID, markType) {166 if (!shouldMark(debugID)) {167 return;168 }169 var markName = debugID + '::' + markType;170 lastMarkTimeStamp = performanceNow();171 performance.mark(markName);172 };173 var markEnd = function markEnd(debugID, markType) {174 if (!shouldMark(debugID)) {175 return;176 }177 var markName = debugID + '::' + markType;178 var displayName = ReactComponentTreeHook.getDisplayName(debugID) || 'Unknown';179 var timeStamp = performanceNow();180 if (timeStamp - lastMarkTimeStamp > 0.1) {181 var measurementName = displayName + ' [' + markType + ']';182 performance.measure(measurementName, markName);183 }184 performance.clearMarks(markName);185 performance.clearMeasures(measurementName);186 };187 ReactDebugTool = {188 addHook: function addHook(hook) {189 hooks.push(hook);190 },191 removeHook: function removeHook(hook) {192 for (var i = 0; i < hooks.length; i++) {193 if (hooks[i] === hook) {194 hooks.splice(i, 1);195 i--;196 }197 }198 },199 isProfiling: function isProfiling() {200 return _isProfiling;201 },202 beginProfiling: function beginProfiling() {203 if (_isProfiling) {204 return;205 }206 _isProfiling = true;207 flushHistory.length = 0;208 resetMeasurements();209 ReactDebugTool.addHook(ReactHostOperationHistoryHook);210 },211 endProfiling: function endProfiling() {212 if (!_isProfiling) {213 return;214 }215 _isProfiling = false;216 resetMeasurements();217 ReactDebugTool.removeHook(ReactHostOperationHistoryHook);218 },219 getFlushHistory: function getFlushHistory() {220 return flushHistory;221 },222 onBeginFlush: function onBeginFlush() {223 currentFlushNesting++;224 resetMeasurements();225 pauseCurrentLifeCycleTimer();226 emitEvent('onBeginFlush');227 },228 onEndFlush: function onEndFlush() {229 resetMeasurements();230 currentFlushNesting--;231 resumeCurrentLifeCycleTimer();232 emitEvent('onEndFlush');233 },234 onBeginLifeCycleTimer: function onBeginLifeCycleTimer(debugID, timerType) {235 checkDebugID(debugID);236 emitEvent('onBeginLifeCycleTimer', debugID, timerType);237 markBegin(debugID, timerType);238 beginLifeCycleTimer(debugID, timerType);239 },240 onEndLifeCycleTimer: function onEndLifeCycleTimer(debugID, timerType) {241 checkDebugID(debugID);242 endLifeCycleTimer(debugID, timerType);243 markEnd(debugID, timerType);...

Full Screen

Full Screen

65b6bd2ffbe6e4c46a631afcc31212818c6d58ReactDebugTool.js

Source:65b6bd2ffbe6e4c46a631afcc31212818c6d58ReactDebugTool.js Github

copy

Full Screen

...55 };56 return tree;57 }, {});58 };59 var resetMeasurements = function resetMeasurements() {60 var previousStartTime = currentFlushStartTime;61 var previousMeasurements = currentFlushMeasurements;62 var previousOperations = ReactHostOperationHistoryHook.getHistory();63 if (currentFlushNesting === 0) {64 currentFlushStartTime = 0;65 currentFlushMeasurements = [];66 clearHistory();67 return;68 }69 if (previousMeasurements.length || previousOperations.length) {70 var registeredIDs = ReactComponentTreeHook.getRegisteredIDs();71 flushHistory.push({72 duration: performanceNow() - previousStartTime,73 measurements: previousMeasurements || [],74 operations: previousOperations || [],75 treeSnapshot: getTreeSnapshot(registeredIDs)76 });77 }78 clearHistory();79 currentFlushStartTime = performanceNow();80 currentFlushMeasurements = [];81 };82 var checkDebugID = function checkDebugID(debugID) {83 var allowRoot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;84 if (allowRoot && debugID === 0) {85 return;86 }87 if (!debugID) {88 warning(false, 'ReactDebugTool: debugID may not be empty.');89 }90 };91 var beginLifeCycleTimer = function beginLifeCycleTimer(debugID, timerType) {92 if (currentFlushNesting === 0) {93 return;94 }95 if (currentTimerType && !lifeCycleTimerHasWarned) {96 warning(false, 'There is an internal error in the React performance measurement code.' + '\n\nDid not expect %s timer to start while %s timer is still in ' + 'progress for %s instance.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another');97 lifeCycleTimerHasWarned = true;98 }99 currentTimerStartTime = performanceNow();100 currentTimerNestedFlushDuration = 0;101 currentTimerDebugID = debugID;102 currentTimerType = timerType;103 };104 var endLifeCycleTimer = function endLifeCycleTimer(debugID, timerType) {105 if (currentFlushNesting === 0) {106 return;107 }108 if (currentTimerType !== timerType && !lifeCycleTimerHasWarned) {109 warning(false, 'There is an internal error in the React performance measurement code. ' + 'We did not expect %s timer to stop while %s timer is still in ' + 'progress for %s instance. Please report this as a bug in React.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another');110 lifeCycleTimerHasWarned = true;111 }112 if (_isProfiling) {113 currentFlushMeasurements.push({114 timerType: timerType,115 instanceID: debugID,116 duration: performanceNow() - currentTimerStartTime - currentTimerNestedFlushDuration117 });118 }119 currentTimerStartTime = 0;120 currentTimerNestedFlushDuration = 0;121 currentTimerDebugID = null;122 currentTimerType = null;123 };124 var pauseCurrentLifeCycleTimer = function pauseCurrentLifeCycleTimer() {125 var currentTimer = {126 startTime: currentTimerStartTime,127 nestedFlushStartTime: performanceNow(),128 debugID: currentTimerDebugID,129 timerType: currentTimerType130 };131 lifeCycleTimerStack.push(currentTimer);132 currentTimerStartTime = 0;133 currentTimerNestedFlushDuration = 0;134 currentTimerDebugID = null;135 currentTimerType = null;136 };137 var resumeCurrentLifeCycleTimer = function resumeCurrentLifeCycleTimer() {138 var _lifeCycleTimerStack$ = lifeCycleTimerStack.pop(),139 startTime = _lifeCycleTimerStack$.startTime,140 nestedFlushStartTime = _lifeCycleTimerStack$.nestedFlushStartTime,141 debugID = _lifeCycleTimerStack$.debugID,142 timerType = _lifeCycleTimerStack$.timerType;143 var nestedFlushDuration = performanceNow() - nestedFlushStartTime;144 currentTimerStartTime = startTime;145 currentTimerNestedFlushDuration += nestedFlushDuration;146 currentTimerDebugID = debugID;147 currentTimerType = timerType;148 };149 var lastMarkTimeStamp = 0;150 var canUsePerformanceMeasure = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function';151 var shouldMark = function shouldMark(debugID) {152 if (!_isProfiling || !canUsePerformanceMeasure) {153 return false;154 }155 var element = ReactComponentTreeHook.getElement(debugID);156 if (element == null || typeof element !== 'object') {157 return false;158 }159 var isHostElement = typeof element.type === 'string';160 if (isHostElement) {161 return false;162 }163 return true;164 };165 var markBegin = function markBegin(debugID, markType) {166 if (!shouldMark(debugID)) {167 return;168 }169 var markName = debugID + '::' + markType;170 lastMarkTimeStamp = performanceNow();171 performance.mark(markName);172 };173 var markEnd = function markEnd(debugID, markType) {174 if (!shouldMark(debugID)) {175 return;176 }177 var markName = debugID + '::' + markType;178 var displayName = ReactComponentTreeHook.getDisplayName(debugID) || 'Unknown';179 var timeStamp = performanceNow();180 if (timeStamp - lastMarkTimeStamp > 0.1) {181 var measurementName = displayName + ' [' + markType + ']';182 performance.measure(measurementName, markName);183 }184 performance.clearMarks(markName);185 performance.clearMeasures(measurementName);186 };187 ReactDebugTool = {188 addHook: function addHook(hook) {189 hooks.push(hook);190 },191 removeHook: function removeHook(hook) {192 for (var i = 0; i < hooks.length; i++) {193 if (hooks[i] === hook) {194 hooks.splice(i, 1);195 i--;196 }197 }198 },199 isProfiling: function isProfiling() {200 return _isProfiling;201 },202 beginProfiling: function beginProfiling() {203 if (_isProfiling) {204 return;205 }206 _isProfiling = true;207 flushHistory.length = 0;208 resetMeasurements();209 ReactDebugTool.addHook(ReactHostOperationHistoryHook);210 },211 endProfiling: function endProfiling() {212 if (!_isProfiling) {213 return;214 }215 _isProfiling = false;216 resetMeasurements();217 ReactDebugTool.removeHook(ReactHostOperationHistoryHook);218 },219 getFlushHistory: function getFlushHistory() {220 return flushHistory;221 },222 onBeginFlush: function onBeginFlush() {223 currentFlushNesting++;224 resetMeasurements();225 pauseCurrentLifeCycleTimer();226 emitEvent('onBeginFlush');227 },228 onEndFlush: function onEndFlush() {229 resetMeasurements();230 currentFlushNesting--;231 resumeCurrentLifeCycleTimer();232 emitEvent('onEndFlush');233 },234 onBeginLifeCycleTimer: function onBeginLifeCycleTimer(debugID, timerType) {235 checkDebugID(debugID);236 emitEvent('onBeginLifeCycleTimer', debugID, timerType);237 markBegin(debugID, timerType);238 beginLifeCycleTimer(debugID, timerType);239 },240 onEndLifeCycleTimer: function onEndLifeCycleTimer(debugID, timerType) {241 checkDebugID(debugID);242 endLifeCycleTimer(debugID, timerType);243 markEnd(debugID, timerType);...

Full Screen

Full Screen

3f3d169c01bb7217eb190766a7508b5a38052fReactDebugTool.js

Source:3f3d169c01bb7217eb190766a7508b5a38052fReactDebugTool.js Github

copy

Full Screen

...55 };56 return tree;57 }, {});58 };59 var resetMeasurements = function resetMeasurements() {60 var previousStartTime = currentFlushStartTime;61 var previousMeasurements = currentFlushMeasurements;62 var previousOperations = ReactHostOperationHistoryHook.getHistory();63 if (currentFlushNesting === 0) {64 currentFlushStartTime = 0;65 currentFlushMeasurements = [];66 clearHistory();67 return;68 }69 if (previousMeasurements.length || previousOperations.length) {70 var registeredIDs = ReactComponentTreeHook.getRegisteredIDs();71 flushHistory.push({72 duration: performanceNow() - previousStartTime,73 measurements: previousMeasurements || [],74 operations: previousOperations || [],75 treeSnapshot: getTreeSnapshot(registeredIDs)76 });77 }78 clearHistory();79 currentFlushStartTime = performanceNow();80 currentFlushMeasurements = [];81 };82 var checkDebugID = function checkDebugID(debugID) {83 var allowRoot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;84 if (allowRoot && debugID === 0) {85 return;86 }87 if (!debugID) {88 warning(false, 'ReactDebugTool: debugID may not be empty.');89 }90 };91 var beginLifeCycleTimer = function beginLifeCycleTimer(debugID, timerType) {92 if (currentFlushNesting === 0) {93 return;94 }95 if (currentTimerType && !lifeCycleTimerHasWarned) {96 warning(false, 'There is an internal error in the React performance measurement code.' + '\n\nDid not expect %s timer to start while %s timer is still in ' + 'progress for %s instance.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another');97 lifeCycleTimerHasWarned = true;98 }99 currentTimerStartTime = performanceNow();100 currentTimerNestedFlushDuration = 0;101 currentTimerDebugID = debugID;102 currentTimerType = timerType;103 };104 var endLifeCycleTimer = function endLifeCycleTimer(debugID, timerType) {105 if (currentFlushNesting === 0) {106 return;107 }108 if (currentTimerType !== timerType && !lifeCycleTimerHasWarned) {109 warning(false, 'There is an internal error in the React performance measurement code. ' + 'We did not expect %s timer to stop while %s timer is still in ' + 'progress for %s instance. Please report this as a bug in React.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another');110 lifeCycleTimerHasWarned = true;111 }112 if (_isProfiling) {113 currentFlushMeasurements.push({114 timerType: timerType,115 instanceID: debugID,116 duration: performanceNow() - currentTimerStartTime - currentTimerNestedFlushDuration117 });118 }119 currentTimerStartTime = 0;120 currentTimerNestedFlushDuration = 0;121 currentTimerDebugID = null;122 currentTimerType = null;123 };124 var pauseCurrentLifeCycleTimer = function pauseCurrentLifeCycleTimer() {125 var currentTimer = {126 startTime: currentTimerStartTime,127 nestedFlushStartTime: performanceNow(),128 debugID: currentTimerDebugID,129 timerType: currentTimerType130 };131 lifeCycleTimerStack.push(currentTimer);132 currentTimerStartTime = 0;133 currentTimerNestedFlushDuration = 0;134 currentTimerDebugID = null;135 currentTimerType = null;136 };137 var resumeCurrentLifeCycleTimer = function resumeCurrentLifeCycleTimer() {138 var _lifeCycleTimerStack$ = lifeCycleTimerStack.pop(),139 startTime = _lifeCycleTimerStack$.startTime,140 nestedFlushStartTime = _lifeCycleTimerStack$.nestedFlushStartTime,141 debugID = _lifeCycleTimerStack$.debugID,142 timerType = _lifeCycleTimerStack$.timerType;143 var nestedFlushDuration = performanceNow() - nestedFlushStartTime;144 currentTimerStartTime = startTime;145 currentTimerNestedFlushDuration += nestedFlushDuration;146 currentTimerDebugID = debugID;147 currentTimerType = timerType;148 };149 var lastMarkTimeStamp = 0;150 var canUsePerformanceMeasure = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function';151 var shouldMark = function shouldMark(debugID) {152 if (!_isProfiling || !canUsePerformanceMeasure) {153 return false;154 }155 var element = ReactComponentTreeHook.getElement(debugID);156 if (element == null || typeof element !== 'object') {157 return false;158 }159 var isHostElement = typeof element.type === 'string';160 if (isHostElement) {161 return false;162 }163 return true;164 };165 var markBegin = function markBegin(debugID, markType) {166 if (!shouldMark(debugID)) {167 return;168 }169 var markName = debugID + '::' + markType;170 lastMarkTimeStamp = performanceNow();171 performance.mark(markName);172 };173 var markEnd = function markEnd(debugID, markType) {174 if (!shouldMark(debugID)) {175 return;176 }177 var markName = debugID + '::' + markType;178 var displayName = ReactComponentTreeHook.getDisplayName(debugID) || 'Unknown';179 var timeStamp = performanceNow();180 if (timeStamp - lastMarkTimeStamp > 0.1) {181 var measurementName = displayName + ' [' + markType + ']';182 performance.measure(measurementName, markName);183 }184 performance.clearMarks(markName);185 performance.clearMeasures(measurementName);186 };187 ReactDebugTool = {188 addHook: function addHook(hook) {189 hooks.push(hook);190 },191 removeHook: function removeHook(hook) {192 for (var i = 0; i < hooks.length; i++) {193 if (hooks[i] === hook) {194 hooks.splice(i, 1);195 i--;196 }197 }198 },199 isProfiling: function isProfiling() {200 return _isProfiling;201 },202 beginProfiling: function beginProfiling() {203 if (_isProfiling) {204 return;205 }206 _isProfiling = true;207 flushHistory.length = 0;208 resetMeasurements();209 ReactDebugTool.addHook(ReactHostOperationHistoryHook);210 },211 endProfiling: function endProfiling() {212 if (!_isProfiling) {213 return;214 }215 _isProfiling = false;216 resetMeasurements();217 ReactDebugTool.removeHook(ReactHostOperationHistoryHook);218 },219 getFlushHistory: function getFlushHistory() {220 return flushHistory;221 },222 onBeginFlush: function onBeginFlush() {223 currentFlushNesting++;224 resetMeasurements();225 pauseCurrentLifeCycleTimer();226 emitEvent('onBeginFlush');227 },228 onEndFlush: function onEndFlush() {229 resetMeasurements();230 currentFlushNesting--;231 resumeCurrentLifeCycleTimer();232 emitEvent('onEndFlush');233 },234 onBeginLifeCycleTimer: function onBeginLifeCycleTimer(debugID, timerType) {235 checkDebugID(debugID);236 emitEvent('onBeginLifeCycleTimer', debugID, timerType);237 markBegin(debugID, timerType);238 beginLifeCycleTimer(debugID, timerType);239 },240 onEndLifeCycleTimer: function onEndLifeCycleTimer(debugID, timerType) {241 checkDebugID(debugID);242 endLifeCycleTimer(debugID, timerType);243 markEnd(debugID, timerType);...

Full Screen

Full Screen

386084ReactDebugTool.js

Source:386084ReactDebugTool.js Github

copy

Full Screen

...55 };56 return tree;57 }, {});58 };59 var resetMeasurements = function resetMeasurements() {60 var previousStartTime = currentFlushStartTime;61 var previousMeasurements = currentFlushMeasurements;62 var previousOperations = ReactHostOperationHistoryHook.getHistory();63 if (currentFlushNesting === 0) {64 currentFlushStartTime = 0;65 currentFlushMeasurements = [];66 clearHistory();67 return;68 }69 if (previousMeasurements.length || previousOperations.length) {70 var registeredIDs = ReactComponentTreeHook.getRegisteredIDs();71 flushHistory.push({72 duration: performanceNow() - previousStartTime,73 measurements: previousMeasurements || [],74 operations: previousOperations || [],75 treeSnapshot: getTreeSnapshot(registeredIDs)76 });77 }78 clearHistory();79 currentFlushStartTime = performanceNow();80 currentFlushMeasurements = [];81 };82 var checkDebugID = function checkDebugID(debugID) {83 var allowRoot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;84 if (allowRoot && debugID === 0) {85 return;86 }87 if (!debugID) {88 warning(false, 'ReactDebugTool: debugID may not be empty.');89 }90 };91 var beginLifeCycleTimer = function beginLifeCycleTimer(debugID, timerType) {92 if (currentFlushNesting === 0) {93 return;94 }95 if (currentTimerType && !lifeCycleTimerHasWarned) {96 warning(false, 'There is an internal error in the React performance measurement code.' + '\n\nDid not expect %s timer to start while %s timer is still in ' + 'progress for %s instance.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another');97 lifeCycleTimerHasWarned = true;98 }99 currentTimerStartTime = performanceNow();100 currentTimerNestedFlushDuration = 0;101 currentTimerDebugID = debugID;102 currentTimerType = timerType;103 };104 var endLifeCycleTimer = function endLifeCycleTimer(debugID, timerType) {105 if (currentFlushNesting === 0) {106 return;107 }108 if (currentTimerType !== timerType && !lifeCycleTimerHasWarned) {109 warning(false, 'There is an internal error in the React performance measurement code. ' + 'We did not expect %s timer to stop while %s timer is still in ' + 'progress for %s instance. Please report this as a bug in React.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another');110 lifeCycleTimerHasWarned = true;111 }112 if (_isProfiling) {113 currentFlushMeasurements.push({114 timerType: timerType,115 instanceID: debugID,116 duration: performanceNow() - currentTimerStartTime - currentTimerNestedFlushDuration117 });118 }119 currentTimerStartTime = 0;120 currentTimerNestedFlushDuration = 0;121 currentTimerDebugID = null;122 currentTimerType = null;123 };124 var pauseCurrentLifeCycleTimer = function pauseCurrentLifeCycleTimer() {125 var currentTimer = {126 startTime: currentTimerStartTime,127 nestedFlushStartTime: performanceNow(),128 debugID: currentTimerDebugID,129 timerType: currentTimerType130 };131 lifeCycleTimerStack.push(currentTimer);132 currentTimerStartTime = 0;133 currentTimerNestedFlushDuration = 0;134 currentTimerDebugID = null;135 currentTimerType = null;136 };137 var resumeCurrentLifeCycleTimer = function resumeCurrentLifeCycleTimer() {138 var _lifeCycleTimerStack$ = lifeCycleTimerStack.pop(),139 startTime = _lifeCycleTimerStack$.startTime,140 nestedFlushStartTime = _lifeCycleTimerStack$.nestedFlushStartTime,141 debugID = _lifeCycleTimerStack$.debugID,142 timerType = _lifeCycleTimerStack$.timerType;143 var nestedFlushDuration = performanceNow() - nestedFlushStartTime;144 currentTimerStartTime = startTime;145 currentTimerNestedFlushDuration += nestedFlushDuration;146 currentTimerDebugID = debugID;147 currentTimerType = timerType;148 };149 var lastMarkTimeStamp = 0;150 var canUsePerformanceMeasure = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function';151 var shouldMark = function shouldMark(debugID) {152 if (!_isProfiling || !canUsePerformanceMeasure) {153 return false;154 }155 var element = ReactComponentTreeHook.getElement(debugID);156 if (element == null || typeof element !== 'object') {157 return false;158 }159 var isHostElement = typeof element.type === 'string';160 if (isHostElement) {161 return false;162 }163 return true;164 };165 var markBegin = function markBegin(debugID, markType) {166 if (!shouldMark(debugID)) {167 return;168 }169 var markName = debugID + '::' + markType;170 lastMarkTimeStamp = performanceNow();171 performance.mark(markName);172 };173 var markEnd = function markEnd(debugID, markType) {174 if (!shouldMark(debugID)) {175 return;176 }177 var markName = debugID + '::' + markType;178 var displayName = ReactComponentTreeHook.getDisplayName(debugID) || 'Unknown';179 var timeStamp = performanceNow();180 if (timeStamp - lastMarkTimeStamp > 0.1) {181 var measurementName = displayName + ' [' + markType + ']';182 performance.measure(measurementName, markName);183 }184 performance.clearMarks(markName);185 performance.clearMeasures(measurementName);186 };187 ReactDebugTool = {188 addHook: function addHook(hook) {189 hooks.push(hook);190 },191 removeHook: function removeHook(hook) {192 for (var i = 0; i < hooks.length; i++) {193 if (hooks[i] === hook) {194 hooks.splice(i, 1);195 i--;196 }197 }198 },199 isProfiling: function isProfiling() {200 return _isProfiling;201 },202 beginProfiling: function beginProfiling() {203 if (_isProfiling) {204 return;205 }206 _isProfiling = true;207 flushHistory.length = 0;208 resetMeasurements();209 ReactDebugTool.addHook(ReactHostOperationHistoryHook);210 },211 endProfiling: function endProfiling() {212 if (!_isProfiling) {213 return;214 }215 _isProfiling = false;216 resetMeasurements();217 ReactDebugTool.removeHook(ReactHostOperationHistoryHook);218 },219 getFlushHistory: function getFlushHistory() {220 return flushHistory;221 },222 onBeginFlush: function onBeginFlush() {223 currentFlushNesting++;224 resetMeasurements();225 pauseCurrentLifeCycleTimer();226 emitEvent('onBeginFlush');227 },228 onEndFlush: function onEndFlush() {229 resetMeasurements();230 currentFlushNesting--;231 resumeCurrentLifeCycleTimer();232 emitEvent('onEndFlush');233 },234 onBeginLifeCycleTimer: function onBeginLifeCycleTimer(debugID, timerType) {235 checkDebugID(debugID);236 emitEvent('onBeginLifeCycleTimer', debugID, timerType);237 markBegin(debugID, timerType);238 beginLifeCycleTimer(debugID, timerType);239 },240 onEndLifeCycleTimer: function onEndLifeCycleTimer(debugID, timerType) {241 checkDebugID(debugID);242 endLifeCycleTimer(debugID, timerType);243 markEnd(debugID, timerType);...

Full Screen

Full Screen

609127ReactDebugTool.js

Source:609127ReactDebugTool.js Github

copy

Full Screen

...55 };56 return tree;57 }, {});58 };59 var resetMeasurements = function resetMeasurements() {60 var previousStartTime = currentFlushStartTime;61 var previousMeasurements = currentFlushMeasurements;62 var previousOperations = ReactHostOperationHistoryHook.getHistory();63 if (currentFlushNesting === 0) {64 currentFlushStartTime = 0;65 currentFlushMeasurements = [];66 clearHistory();67 return;68 }69 if (previousMeasurements.length || previousOperations.length) {70 var registeredIDs = ReactComponentTreeHook.getRegisteredIDs();71 flushHistory.push({72 duration: performanceNow() - previousStartTime,73 measurements: previousMeasurements || [],74 operations: previousOperations || [],75 treeSnapshot: getTreeSnapshot(registeredIDs)76 });77 }78 clearHistory();79 currentFlushStartTime = performanceNow();80 currentFlushMeasurements = [];81 };82 var checkDebugID = function checkDebugID(debugID) {83 var allowRoot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;84 if (allowRoot && debugID === 0) {85 return;86 }87 if (!debugID) {88 warning(false, 'ReactDebugTool: debugID may not be empty.');89 }90 };91 var beginLifeCycleTimer = function beginLifeCycleTimer(debugID, timerType) {92 if (currentFlushNesting === 0) {93 return;94 }95 if (currentTimerType && !lifeCycleTimerHasWarned) {96 warning(false, 'There is an internal error in the React performance measurement code.' + '\n\nDid not expect %s timer to start while %s timer is still in ' + 'progress for %s instance.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another');97 lifeCycleTimerHasWarned = true;98 }99 currentTimerStartTime = performanceNow();100 currentTimerNestedFlushDuration = 0;101 currentTimerDebugID = debugID;102 currentTimerType = timerType;103 };104 var endLifeCycleTimer = function endLifeCycleTimer(debugID, timerType) {105 if (currentFlushNesting === 0) {106 return;107 }108 if (currentTimerType !== timerType && !lifeCycleTimerHasWarned) {109 warning(false, 'There is an internal error in the React performance measurement code. ' + 'We did not expect %s timer to stop while %s timer is still in ' + 'progress for %s instance. Please report this as a bug in React.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another');110 lifeCycleTimerHasWarned = true;111 }112 if (_isProfiling) {113 currentFlushMeasurements.push({114 timerType: timerType,115 instanceID: debugID,116 duration: performanceNow() - currentTimerStartTime - currentTimerNestedFlushDuration117 });118 }119 currentTimerStartTime = 0;120 currentTimerNestedFlushDuration = 0;121 currentTimerDebugID = null;122 currentTimerType = null;123 };124 var pauseCurrentLifeCycleTimer = function pauseCurrentLifeCycleTimer() {125 var currentTimer = {126 startTime: currentTimerStartTime,127 nestedFlushStartTime: performanceNow(),128 debugID: currentTimerDebugID,129 timerType: currentTimerType130 };131 lifeCycleTimerStack.push(currentTimer);132 currentTimerStartTime = 0;133 currentTimerNestedFlushDuration = 0;134 currentTimerDebugID = null;135 currentTimerType = null;136 };137 var resumeCurrentLifeCycleTimer = function resumeCurrentLifeCycleTimer() {138 var _lifeCycleTimerStack$ = lifeCycleTimerStack.pop(),139 startTime = _lifeCycleTimerStack$.startTime,140 nestedFlushStartTime = _lifeCycleTimerStack$.nestedFlushStartTime,141 debugID = _lifeCycleTimerStack$.debugID,142 timerType = _lifeCycleTimerStack$.timerType;143 var nestedFlushDuration = performanceNow() - nestedFlushStartTime;144 currentTimerStartTime = startTime;145 currentTimerNestedFlushDuration += nestedFlushDuration;146 currentTimerDebugID = debugID;147 currentTimerType = timerType;148 };149 var lastMarkTimeStamp = 0;150 var canUsePerformanceMeasure = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function';151 var shouldMark = function shouldMark(debugID) {152 if (!_isProfiling || !canUsePerformanceMeasure) {153 return false;154 }155 var element = ReactComponentTreeHook.getElement(debugID);156 if (element == null || typeof element !== 'object') {157 return false;158 }159 var isHostElement = typeof element.type === 'string';160 if (isHostElement) {161 return false;162 }163 return true;164 };165 var markBegin = function markBegin(debugID, markType) {166 if (!shouldMark(debugID)) {167 return;168 }169 var markName = debugID + '::' + markType;170 lastMarkTimeStamp = performanceNow();171 performance.mark(markName);172 };173 var markEnd = function markEnd(debugID, markType) {174 if (!shouldMark(debugID)) {175 return;176 }177 var markName = debugID + '::' + markType;178 var displayName = ReactComponentTreeHook.getDisplayName(debugID) || 'Unknown';179 var timeStamp = performanceNow();180 if (timeStamp - lastMarkTimeStamp > 0.1) {181 var measurementName = displayName + ' [' + markType + ']';182 performance.measure(measurementName, markName);183 }184 performance.clearMarks(markName);185 performance.clearMeasures(measurementName);186 };187 ReactDebugTool = {188 addHook: function addHook(hook) {189 hooks.push(hook);190 },191 removeHook: function removeHook(hook) {192 for (var i = 0; i < hooks.length; i++) {193 if (hooks[i] === hook) {194 hooks.splice(i, 1);195 i--;196 }197 }198 },199 isProfiling: function isProfiling() {200 return _isProfiling;201 },202 beginProfiling: function beginProfiling() {203 if (_isProfiling) {204 return;205 }206 _isProfiling = true;207 flushHistory.length = 0;208 resetMeasurements();209 ReactDebugTool.addHook(ReactHostOperationHistoryHook);210 },211 endProfiling: function endProfiling() {212 if (!_isProfiling) {213 return;214 }215 _isProfiling = false;216 resetMeasurements();217 ReactDebugTool.removeHook(ReactHostOperationHistoryHook);218 },219 getFlushHistory: function getFlushHistory() {220 return flushHistory;221 },222 onBeginFlush: function onBeginFlush() {223 currentFlushNesting++;224 resetMeasurements();225 pauseCurrentLifeCycleTimer();226 emitEvent('onBeginFlush');227 },228 onEndFlush: function onEndFlush() {229 resetMeasurements();230 currentFlushNesting--;231 resumeCurrentLifeCycleTimer();232 emitEvent('onEndFlush');233 },234 onBeginLifeCycleTimer: function onBeginLifeCycleTimer(debugID, timerType) {235 checkDebugID(debugID);236 emitEvent('onBeginLifeCycleTimer', debugID, timerType);237 markBegin(debugID, timerType);238 beginLifeCycleTimer(debugID, timerType);239 },240 onEndLifeCycleTimer: function onEndLifeCycleTimer(debugID, timerType) {241 checkDebugID(debugID);242 endLifeCycleTimer(debugID, timerType);243 markEnd(debugID, timerType);...

Full Screen

Full Screen

ReactDebugTool.js

Source:ReactDebugTool.js Github

copy

Full Screen

...64 };65 return tree;66 }, {});67}68function resetMeasurements() {69 var previousStartTime = currentFlushStartTime;70 var previousMeasurements = currentFlushMeasurements;71 var previousOperations = ReactHostOperationHistoryHook.getHistory();72 if (currentFlushNesting === 0) {73 currentFlushStartTime = 0;74 currentFlushMeasurements = [];75 clearHistory();76 return;77 }78 if (previousMeasurements.length || previousOperations.length) {79 var registeredIDs = ReactComponentTreeHook.getRegisteredIDs();80 flushHistory.push({81 duration: performanceNow() - previousStartTime,82 measurements: previousMeasurements || [],83 operations: previousOperations || [],84 treeSnapshot: getTreeSnapshot(registeredIDs)85 });86 }87 clearHistory();88 currentFlushStartTime = performanceNow();89 currentFlushMeasurements = [];90}91function checkDebugID(debugID) {92 var allowRoot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;93 if (allowRoot && debugID === 0) {94 return;95 }96 if (!debugID) {97 process.env.NODE_ENV !== 'production' ? warning(false, 'ReactDebugTool: debugID may not be empty.') : void 0;98 }99}100function beginLifeCycleTimer(debugID, timerType) {101 if (currentFlushNesting === 0) {102 return;103 }104 if (currentTimerType && !lifeCycleTimerHasWarned) {105 process.env.NODE_ENV !== 'production' ? warning(false, 'There is an internal error in the React performance measurement code. ' + 'Did not expect %s timer to start while %s timer is still in ' + 'progress for %s instance.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another') : void 0;106 lifeCycleTimerHasWarned = true;107 }108 currentTimerStartTime = performanceNow();109 currentTimerNestedFlushDuration = 0;110 currentTimerDebugID = debugID;111 currentTimerType = timerType;112}113function endLifeCycleTimer(debugID, timerType) {114 if (currentFlushNesting === 0) {115 return;116 }117 if (currentTimerType !== timerType && !lifeCycleTimerHasWarned) {118 process.env.NODE_ENV !== 'production' ? warning(false, 'There is an internal error in the React performance measurement code. ' + 'We did not expect %s timer to stop while %s timer is still in ' + 'progress for %s instance. Please report this as a bug in React.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another') : void 0;119 lifeCycleTimerHasWarned = true;120 }121 if (isProfiling) {122 currentFlushMeasurements.push({123 timerType: timerType,124 instanceID: debugID,125 duration: performanceNow() - currentTimerStartTime - currentTimerNestedFlushDuration126 });127 }128 currentTimerStartTime = 0;129 currentTimerNestedFlushDuration = 0;130 currentTimerDebugID = null;131 currentTimerType = null;132}133function pauseCurrentLifeCycleTimer() {134 var currentTimer = {135 startTime: currentTimerStartTime,136 nestedFlushStartTime: performanceNow(),137 debugID: currentTimerDebugID,138 timerType: currentTimerType139 };140 lifeCycleTimerStack.push(currentTimer);141 currentTimerStartTime = 0;142 currentTimerNestedFlushDuration = 0;143 currentTimerDebugID = null;144 currentTimerType = null;145}146function resumeCurrentLifeCycleTimer() {147 var _lifeCycleTimerStack$ = lifeCycleTimerStack.pop(),148 startTime = _lifeCycleTimerStack$.startTime,149 nestedFlushStartTime = _lifeCycleTimerStack$.nestedFlushStartTime,150 debugID = _lifeCycleTimerStack$.debugID,151 timerType = _lifeCycleTimerStack$.timerType;152 var nestedFlushDuration = performanceNow() - nestedFlushStartTime;153 currentTimerStartTime = startTime;154 currentTimerNestedFlushDuration += nestedFlushDuration;155 currentTimerDebugID = debugID;156 currentTimerType = timerType;157}158var lastMarkTimeStamp = 0;159var canUsePerformanceMeasure =160// $FlowFixMe https://github.com/facebook/flow/issues/2345161typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function';162function shouldMark(debugID) {163 if (!isProfiling || !canUsePerformanceMeasure) {164 return false;165 }166 var element = ReactComponentTreeHook.getElement(debugID);167 if (element == null || typeof element !== 'object') {168 return false;169 }170 var isHostElement = typeof element.type === 'string';171 if (isHostElement) {172 return false;173 }174 return true;175}176function markBegin(debugID, markType) {177 if (!shouldMark(debugID)) {178 return;179 }180 var markName = debugID + '::' + markType;181 lastMarkTimeStamp = performanceNow();182 performance.mark(markName);183}184function markEnd(debugID, markType) {185 if (!shouldMark(debugID)) {186 return;187 }188 var markName = debugID + '::' + markType;189 var displayName = ReactComponentTreeHook.getDisplayName(debugID) || 'Unknown';190 // Chrome has an issue of dropping markers recorded too fast:191 // https://bugs.chromium.org/p/chromium/issues/detail?id=640652192 // To work around this, we will not report very small measurements.193 // I determined the magic number by tweaking it back and forth.194 // 0.05ms was enough to prevent the issue, but I set it to 0.1ms to be safe.195 // When the bug is fixed, we can `measure()` unconditionally if we want to.196 var timeStamp = performanceNow();197 if (timeStamp - lastMarkTimeStamp > 0.1) {198 var measurementName = displayName + ' [' + markType + ']';199 performance.measure(measurementName, markName);200 }201 performance.clearMarks(markName);202 performance.clearMeasures(measurementName);203}204var ReactDebugTool = {205 addHook: function (hook) {206 hooks.push(hook);207 },208 removeHook: function (hook) {209 for (var i = 0; i < hooks.length; i++) {210 if (hooks[i] === hook) {211 hooks.splice(i, 1);212 i--;213 }214 }215 },216 isProfiling: function () {217 return isProfiling;218 },219 beginProfiling: function () {220 if (isProfiling) {221 return;222 }223 isProfiling = true;224 flushHistory.length = 0;225 resetMeasurements();226 ReactDebugTool.addHook(ReactHostOperationHistoryHook);227 },228 endProfiling: function () {229 if (!isProfiling) {230 return;231 }232 isProfiling = false;233 resetMeasurements();234 ReactDebugTool.removeHook(ReactHostOperationHistoryHook);235 },236 getFlushHistory: function () {237 return flushHistory;238 },239 onBeginFlush: function () {240 currentFlushNesting++;241 resetMeasurements();242 pauseCurrentLifeCycleTimer();243 emitEvent('onBeginFlush');244 },245 onEndFlush: function () {246 resetMeasurements();247 currentFlushNesting--;248 resumeCurrentLifeCycleTimer();249 emitEvent('onEndFlush');250 },251 onBeginLifeCycleTimer: function (debugID, timerType) {252 checkDebugID(debugID);253 emitEvent('onBeginLifeCycleTimer', debugID, timerType);254 markBegin(debugID, timerType);255 beginLifeCycleTimer(debugID, timerType);256 },257 onEndLifeCycleTimer: function (debugID, timerType) {258 checkDebugID(debugID);259 endLifeCycleTimer(debugID, timerType);260 markEnd(debugID, timerType);...

Full Screen

Full Screen

CellMeasurer.js

Source:CellMeasurer.js Github

copy

Full Screen

1/** @flow */2import React, { Component, PropTypes } from 'react'3import shallowCompare from 'react-addons-shallow-compare'4import ReactDOM from 'react-dom'5import CellSizeCache from './defaultCellSizeCache'6/**7 * Measures a Grid cell's contents by rendering them in a way that is not visible to the user.8 * Either a fixed width or height may be provided if it is desirable to measure only in one direction.9 */10export default class CellMeasurer extends Component {11 static propTypes = {12 /**13 * Renders a cell given its indices.14 * Should implement the following interface: ({ columnIndex: number, rowIndex: number }): PropTypes.node15 */16 cellRenderer: PropTypes.func.isRequired,17 /**18 * Optional, custom caching strategy for cell sizes.19 */20 cellSizeCache: PropTypes.object,21 /**22 * Function respondible for rendering a virtualized component.23 * This function should implement the following signature:24 * ({ getColumnWidth, getRowHeight, resetMeasurements }) => PropTypes.element25 */26 children: PropTypes.func.isRequired,27 /**28 * Number of columns in grid.29 */30 columnCount: PropTypes.number.isRequired,31 /**32 * A Node, Component instance, or function that returns either.33 * If this property is not specified the document body will be used.34 */35 container: React.PropTypes.oneOfType([36 React.PropTypes.func,37 React.PropTypes.node38 ]),39 /**40 * Assign a fixed :height in order to measure dynamic text :width only.41 */42 height: PropTypes.number,43 /**44 * Number of rows in grid.45 */46 rowCount: PropTypes.number.isRequired,47 /**48 * Assign a fixed :width in order to measure dynamic text :height only.49 */50 width: PropTypes.number51 };52 constructor (props, state) {53 super(props, state)54 this._cellSizeCache = props.cellSizeCache || new CellSizeCache()55 this.getColumnWidth = this.getColumnWidth.bind(this)56 this.getRowHeight = this.getRowHeight.bind(this)57 this.resetMeasurements = this.resetMeasurements.bind(this)58 this.resetMeasurementForColumn = this.resetMeasurementForColumn.bind(this)59 this.resetMeasurementForRow = this.resetMeasurementForRow.bind(this)60 }61 getColumnWidth ({ index }) {62 if (this._cellSizeCache.hasColumnWidth(index)) {63 return this._cellSizeCache.getColumnWidth(index)64 }65 const { rowCount } = this.props66 let maxWidth = 067 for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {68 let { width } = this._measureCell({69 clientWidth: true,70 columnIndex: index,71 rowIndex72 })73 maxWidth = Math.max(maxWidth, width)74 }75 this._cellSizeCache.setColumnWidth(index, maxWidth)76 return maxWidth77 }78 getRowHeight ({ index }) {79 if (this._cellSizeCache.hasRowHeight(index)) {80 return this._cellSizeCache.getRowHeight(index)81 }82 const { columnCount } = this.props83 let maxHeight = 084 for (let columnIndex = 0; columnIndex < columnCount; columnIndex++) {85 let { height } = this._measureCell({86 clientHeight: true,87 columnIndex,88 rowIndex: index89 })90 maxHeight = Math.max(maxHeight, height)91 }92 this._cellSizeCache.setRowHeight(index, maxHeight)93 return maxHeight94 }95 resetMeasurementForColumn (columnIndex) {96 this._cellSizeCache.clearColumnWidth(columnIndex)97 }98 resetMeasurementForRow (rowIndex) {99 this._cellSizeCache.clearRowHeight(rowIndex)100 }101 resetMeasurements () {102 this._cellSizeCache.clearAllColumnWidths()103 this._cellSizeCache.clearAllRowHeights()104 }105 componentDidMount () {106 this._renderAndMount()107 }108 componentWillReceiveProps (nextProps) {109 const { cellSizeCache } = this.props110 if (cellSizeCache !== nextProps.cellSizeCache) {111 this._cellSizeCache = nextProps.cellSizeCache112 }113 this._updateDivDimensions(nextProps)114 }115 componentWillUnmount () {116 this._unmountContainer()117 }118 render () {119 const { children } = this.props120 return children({121 getColumnWidth: this.getColumnWidth,122 getRowHeight: this.getRowHeight,123 resetMeasurements: this.resetMeasurements,124 resetMeasurementForColumn: this.resetMeasurementForColumn,125 resetMeasurementForRow: this.resetMeasurementForRow126 })127 }128 shouldComponentUpdate (nextProps, nextState) {129 return shallowCompare(this, nextProps, nextState)130 }131 _getContainerNode (props) {132 const { container } = props133 if (container) {134 return ReactDOM.findDOMNode(135 typeof container === 'function'136 ? container()137 : container138 )139 } else {140 return document.body141 }142 }143 _measureCell ({144 clientHeight = false,145 clientWidth = true,146 columnIndex,147 rowIndex148 }) {149 const { cellRenderer } = this.props150 const rendered = cellRenderer({151 columnIndex,152 rowIndex153 })154 // Handle edge case where this method is called before the CellMeasurer has completed its initial render (and mounted).155 this._renderAndMount()156 // @TODO Keep an eye on this for future React updates as the interface may change:157 // https://twitter.com/soprano/status/737316379712331776158 ReactDOM.unstable_renderSubtreeIntoContainer(this, rendered, this._div)159 const measurements = {160 height: clientHeight && this._div.clientHeight,161 width: clientWidth && this._div.clientWidth162 }163 ReactDOM.unmountComponentAtNode(this._div)164 return measurements165 }166 _renderAndMount () {167 if (!this._div) {168 this._div = document.createElement('div')169 this._div.style.display = 'inline-block'170 this._div.style.position = 'absolute'171 this._div.style.visibility = 'hidden'172 this._div.style.zIndex = -1173 this._updateDivDimensions(this.props)174 this._containerNode = this._getContainerNode(this.props)175 this._containerNode.appendChild(this._div)176 }177 }178 _unmountContainer () {179 if (this._div) {180 this._containerNode.removeChild(this._div)181 this._div = null182 }183 this._containerNode = null184 }185 _updateDivDimensions (props) {186 const { height, width } = props187 if (188 height &&189 height !== this._divHeight190 ) {191 this._divHeight = height192 this._div.style.height = `${height}px`193 }194 if (195 width &&196 width !== this._divWidth197 ) {198 this._divWidth = width199 this._div.style.width = `${width}px`200 }201 }...

Full Screen

Full Screen

measurer.js

Source:measurer.js Github

copy

Full Screen

...19 } else {20 return Date.now();21 }22}23function resetMeasurements() {24 if (currentMeasurements.length) {25 data.push({26 duration: now() - currentStartTime,27 measurements: currentMeasurements,28 operations: operations,29 tree: tree30 });31 }32 currentStartTime = now();33 currentMeasurements = [];34}35function clear() {36 currentStartTime = 0;37 currentNestedDuration = 0;38}39const Measurer = {40 begin() {41 if (profiling) {42 return;43 }44 profiling = true;45 data = [];46 resetMeasurements();47 },48 end() {49 if (!profiling) {50 return;51 }52 profiling = false;53 resetMeasurements();54 },55 beforeRender() {56 currentNesting++;57 resetMeasurements();58 clear();59 },60 afterRender() {61 resetMeasurements();62 currentNesting--;63 },64 beforeMountComponent(instanceID, element) {65 tree[instanceID] = element;66 // root67 if (element.getName() === 'Root') {68 roots[instanceID] = element;69 }70 },71 afterMountComponent(instanceID) {72 const item = tree[instanceID];73 item.isMounted = true;74 },75 beforeUpdateComponent(instanceID, element) {...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2const { chromium } = playwright;3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.resetMeasurements();8 await browser.close();9})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2(async () => {3 const browser = await playwright.chromium.launch();4 const page = await browser.newPage();5 await page.tracing.start({ screenshots: true, snapshots: true });6 await page.click('text=Get started');7 await page.tracing.stop({ path: 'trace.zip' });8 await browser.close();9})();10const playwright = require('playwright');11(async () => {12 const browser = await playwright.chromium.launch();13 const page = await browser.newPage();14 await page.tracing.start({ screenshots: true, snapshots: true });15 await page.click('text=Get started');16 await page.tracing.stop({ path: 'trace.zip' });17 await browser.close();18})();19const playwright = require('playwright');20(async () => {21 const browser = await playwright.chromium.launch();22 const page = await browser.newPage();23 await page.tracing.start({ screenshots: true, snapshots: true });24 await page.click('text=Get started');25 await page.tracing.stop({ path: 'trace.zip' });26 await browser.close();27})();28const playwright = require('playwright');29(async () => {30 const browser = await playwright.chromium.launch();31 const page = await browser.newPage();32 await page.tracing.start({ screenshots: true, snapshots: true });33 await page.click('text=Get started');34 await page.tracing.stop({ path: 'trace.zip' });35 await browser.close();36})();37const playwright = require('playwright');38(async () => {39 const browser = await playwright.chromium.launch();40 const page = await browser.newPage();41 await page.tracing.start({ screenshots: true, snapshots: true });42 await page.click('text=Get started');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2const path = require('path');3const fs = require('fs');4(async () => {5 const browser = await chromium.launch();6 const context = await browser.newContext();7 const page = await context.newPage();8 await page.waitForSelector('input[name="q"]')9 await page.type('input[name="q"]', 'Playwright');10 await page.screenshot({ path: `example.png` });11 await page.evaluate(() => {12 window.__playwright__resetMeasurements();13 });14 const metrics = await page.metrics();15 console.log(metrics);16 await browser.close();17})();18{19}20const { chromium } = require('playwright');21const path = require('path');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { resetMeasurements } = require('playwright/lib/server/chromium/crNetwork');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 await page.screenshot({ path: 'google.png' });8 await browser.close();9})();10 at CDPSession._onMessage (D:\playwright\playwright-examples\node_modules\playwright\lib\server\cdp.js:69:35)11 at CDPSession.emit (events.js:315:20)12 at CDPSession._onMessage (D:\playwright\playwright-examples\node_modules\playwright\lib\server\cdpSession.js:96:14)13 at CDPSession.emit (events.js:315:20)14 at WebSocketTransport._ws.addEventListener.event (D:\playwright\playwright-examples\node_modules\playwright\lib\server\cdpSession.js:34:22)15 at WebSocketTransport.emit (events.js:315:20)16 at WebSocketTransport._ws.onmessage (D:\playwright\playwright-examples\node_modules\playwright\lib\server\transport.js:49:20)17 at WebSocket.onMessage (D:\playwright\playwright-examples\node_modules\ws\lib\event-target.js:132:16)18 at WebSocket.emit (events.js:315:20)19 at Receiver.receiverOnMessage (D:\playwright\playwright-examples\node_modules\ws\lib\websocket.js:789:20)

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.evaluate(() => {7 window.__playwright__internal__resetMeasurements();8 });9 const memory = await page.evaluate(() => {10 return window.performance.memory;11 });12 console.log(memory);13 await browser.close();14})();15{16}

Full Screen

Using AI Code Generation

copy

Full Screen

1const { resetMeasurements } = require('playwright/lib/server/supplements/recorder/recorderMeasurements');2resetMeasurements();3const { resetMeasurements } = require('playwright/lib/server/supplements/recorder/recorderMeasurements');4resetMeasurements();5const { chromium } = require('playwright');6const { resetMeasurements } = require('playwright/lib/server/supplements/recorder/recorderMeasurements');7(async () => {8 const browser = await chromium.launch();9 resetMeasurements();10 const context = await browser.newContext();11 const page = await context.newPage();12 await page.close();13 await context.close();14 await browser.close();15})();16const { chromium } = require('playwright');17const { resetMeasurements } = require('playwright/lib/server/supplements/recorder/recorderMeasurements');18(async () => {19 const browser = await chromium.launch();20 const context = await browser.newContext();21 resetMeasurements();22 const page = await context.newPage();23 await page.close();24 await context.close();25 await browser.close();26})();27const { chromium } = require('playwright');28const { resetMeasurements } = require('playwright/lib/server/supplements/recorder/recorderMeasurements');29(async () => {30 const browser = await chromium.launch();31 const context = await browser.newContext();32 const page = await context.newPage();33 resetMeasurements();34 await page.close();35 await context.close();36 await browser.close();37})();38const { chromium } = require('playwright');39const { resetMeasurements } = require('playwright/lib/server/supplements/recorder/recorderMeasurements');40(async () => {41 const browser = await chromium.launch();42 const context = await browser.newContext();43 const page = await context.newPage();44 resetMeasurements();45 await page.close();46 await context.close();47 await browser.close();48})();49const { chromium } = require('playwright');50const { resetMeasurements

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2const { resetMeasurements } = require('playwright/lib/server/chromium/crNetworkManager');3const { chromium } = playwright;4(async () => {5 const browser = await chromium.launch();6 const context = await browser.newContext();7 const page = await context.newPage();8 await page.waitForTimeout(5000);9 const test = resetMeasurements(page);10 console.log(test);11 await browser.close();12})();13module.exports = {14 launchOptions: {15 },16 contextOptions: {17 viewport: {18 },19 },20 use: {21 viewport: {22 },23 },24};25module.exports = {26 launchOptions: {27 },28 contextOptions: {29 viewport: {30 },31 },

Full Screen

Using AI Code Generation

copy

Full Screen

1import { chromium, devices, webkit, firefox } from 'playwright';2import { resetMeasurements } from 'playwright/lib/server/chromium/crNetworkManager';3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const metrics = await page.evaluate(() => window.performance.getEntriesByType('resource'));8 console.log(metrics);9 resetMeasurements();10 await page.reload();11 const metrics2 = await page.evaluate(() => window.performance.getEntriesByType('resource'));12 console.log(metrics2);13 await browser.close();14})();15const route = await page.route('**/*');16page.on('request', request => {17 console.log(request.url());18});19page.on('response', response => {20 console.log(response.url());21});22import { test } from '@playwright/test';23test('example', async ({ page }) => {24 await page.route('**/*', route => {25 console.log(route.request().url());26 route.continue();27 });28});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.resetMeasurements();7 await page.click('text=Get started');8 const metrics = await page.metrics();9 console.log(metrics);10 await browser.close();11})();

Full Screen

Playwright tutorial

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.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful