Skip to content

Commit

Permalink
Add performance timings handling for SearchRouterList
Browse files Browse the repository at this point in the history
  • Loading branch information
Kicu committed Oct 4, 2024
1 parent 4052f9a commit cb51d04
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/components/Search/SearchRouter/SearchButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ function SearchButton() {
accessibilityLabel={translate('common.search')}
style={[styles.flexRow, styles.touchableButtonImage]}
onPress={Session.checkIfActionIsAllowed(() => {
// Todo [Search] add finishing for this timing in <SearchRouterList>
Timing.start(CONST.TIMING.SEARCH_ROUTER_OPEN);
Performance.markStart(CONST.TIMING.SEARCH_ROUTER_OPEN);

Expand Down
3 changes: 3 additions & 0 deletions src/components/Search/SearchRouter/SearchRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import * as SearchUtils from '@libs/SearchUtils';
import Navigation from '@navigation/Navigation';
import variables from '@styles/variables';
import * as Report from '@userActions/Report';
import Timing from '@userActions/Timing';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
Expand Down Expand Up @@ -65,7 +66,9 @@ function SearchRouter() {
};
}

Timing.start(CONST.TIMING.SEARCH_FILTER_OPTIONS);
const newOptions = OptionsListUtils.filterOptions(searchOptions, debouncedInputValue, {sortByReportTypeInSearch: true, preferChatroomsOverThreads: true});
Timing.end(CONST.TIMING.SEARCH_FILTER_OPTIONS);

return {
recentReports: newOptions.recentReports,
Expand Down
9 changes: 9 additions & 0 deletions src/components/Search/SearchRouter/SearchRouterList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ import useLocalize from '@hooks/useLocalize';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import Performance from '@libs/Performance';
import {getAllTaxRates} from '@libs/PolicyUtils';
import type {OptionData} from '@libs/ReportUtils';
import * as SearchUtils from '@libs/SearchUtils';
import * as Report from '@userActions/Report';
import Timing from '@userActions/Timing';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';

Expand Down Expand Up @@ -47,6 +50,11 @@ type SearchRouterListProps = {
closeAndClearRouter: () => void;
};

const setPerformanceTimersEnd = () => {
Timing.end(CONST.TIMING.SEARCH_ROUTER_OPEN);
Performance.markEnd(CONST.TIMING.SEARCH_ROUTER_OPEN);
};

function isSearchQueryItem(item: OptionData | SearchQueryItem): item is SearchQueryItem {
if ('singleIcon' in item && item.singleIcon && 'query' in item && item.query) {
return true;
Expand Down Expand Up @@ -174,6 +182,7 @@ function SearchRouterList(
ListItem={SearchRouterItem}
containerStyle={[styles.mh100]}
sectionListStyle={[isSmallScreenWidth ? styles.ph5 : styles.ph2, styles.pb2]}
onLayout={setPerformanceTimersEnd}
ref={ref}
showScrollIndicator={!isSmallScreenWidth}
/>
Expand Down
6 changes: 3 additions & 3 deletions src/libs/E2E/tests/openSearchRouterTest.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ const test = () => {

console.debug('[E2E] Logged in, getting search router metrics and submitting them…');

const [openSearchPagePromise, openSearchPageResolve] = getPromiseWithResolve();
const [openSearchRouterPromise, openSearchRouterResolve] = getPromiseWithResolve();
const [loadSearchOptionsPromise, loadSearchOptionsResolve] = getPromiseWithResolve();

Promise.all([openSearchPagePromise, loadSearchOptionsPromise]).then(() => {
Promise.all([openSearchRouterPromise, loadSearchOptionsPromise]).then(() => {
console.debug(`[E2E] Submitting!`);

E2EClient.submitTestDone();
Expand All @@ -40,7 +40,7 @@ const test = () => {
unit: 'ms',
})
.then(() => {
openSearchPageResolve();
openSearchRouterResolve();
console.debug('[E2E] Done with search, exiting…');
})
.catch((err) => {
Expand Down

0 comments on commit cb51d04

Please sign in to comment.