Remove unused performance metrics

* Removes lines from instrumentation.js

Bug: T379861
Change-Id: I2943917db477cd33fab481eaf24e50f6f01ca412
This commit is contained in:
ksarabia 2024-12-03 09:55:39 -06:00
parent 6988e66271
commit 8b197f417d

View file

@ -4,37 +4,6 @@
* *
* @see https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/skins/Vector/+/refs/heads/master/includes/Constants.php * @see https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/skins/Vector/+/refs/heads/master/includes/Constants.php
*/ */
const INPUT_LOCATION_MOVED = 'header-moved',
// T251544: Collect search performance metrics to compare Vue search with
// mediawiki.searchSuggest performance. Marks and Measures will only be
// recorded on the Vector skin and only if browser supported.
shouldTestSearchPerformance = !!( window.performance &&
!!performance.mark &&
!!performance.measure &&
!!performance.getEntriesByName &&
performance.clearMarks ),
loadStartMark = 'mwVectorVueSearchLoadStart',
queryMark = 'mwVectorVueSearchQuery',
renderMark = 'mwVectorVueSearchRender',
queryToRenderMeasure = 'mwVectorVueSearchQueryToRender',
loadStartToFirstRenderMeasure = 'mwVectorVueSearchLoadStartToFirstRender';
function onFetchStart() {
if ( !shouldTestSearchPerformance ) {
return;
}
// Clear past marks that are no longer relevant. This likely means that the
// search request failed or was cancelled. Whatever the reason, the mark
// is no longer needed since we are only interested in collecting the time
// from query to render.
if ( performance.getEntriesByName( queryMark ).length ) {
performance.clearMarks( queryMark );
}
performance.mark( queryMark );
}
/** /**
* @param {FetchEndEvent} event * @param {FetchEndEvent} event
*/ */
@ -45,38 +14,8 @@ function onFetchEnd( event ) {
// resultSetType: '', // resultSetType: '',
// searchId: '', // searchId: '',
query: event.query, query: event.query,
inputLocation: INPUT_LOCATION_MOVED inputLocation: 'header-moved'
} ); } );
if ( shouldTestSearchPerformance ) {
// Schedule the mark after the search results have rendered and are
// visible to the user. Two rAF's are needed for this since rAF will
// execute before the rendering steps happen (e.g. layout and paint). A
// nested rAF will execute after these rendering steps have completed
// and ensure the search results are visible to the user.
requestAnimationFrame( () => {
requestAnimationFrame( () => {
if ( !performance.getEntriesByName( queryMark ).length ) {
return;
}
performance.mark( renderMark );
performance.measure( queryToRenderMeasure, queryMark, renderMark );
// Measure from the start of the lazy load to the first render if we
// haven't already captured that info.
if ( performance.getEntriesByName( loadStartMark ).length &&
!performance.getEntriesByName( loadStartToFirstRenderMeasure ).length ) {
performance.measure( loadStartToFirstRenderMeasure, loadStartMark, renderMark );
}
// The measures are the most meaningful info so we remove the marks
// after we have the measure.
performance.clearMarks( queryMark );
performance.clearMarks( renderMark );
} );
} );
}
} }
/** /**
@ -143,7 +82,6 @@ function addWprovToSearchResultUrls( results, offset ) {
*/ */
module.exports = { module.exports = {
listeners: { listeners: {
onFetchStart,
onFetchEnd, onFetchEnd,
onSuggestionClick, onSuggestionClick,