Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(settings): add profiler #1538

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,9 @@ PODS:
- React-Core
- react-native-randombytes (3.6.1):
- React-Core
- react-native-release-profiler (0.1.6):
- RCT-Folly (= 2021.07.22.00)
- React-Core
- react-native-restart (0.0.27):
- React-Core
- react-native-safe-area-context (4.7.4):
Expand Down Expand Up @@ -645,6 +648,7 @@ DEPENDENCIES:
- react-native-quick-base64 (from `../node_modules/react-native-quick-base64`)
- react-native-quick-crypto (from `../node_modules/react-native-quick-crypto`)
- react-native-randombytes (from `../node_modules/react-native-randombytes`)
- react-native-release-profiler (from `../node_modules/react-native-release-profiler`)
- react-native-restart (from `../node_modules/react-native-restart`)
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
- "react-native-skia (from `../node_modules/@shopify/react-native-skia`)"
Expand Down Expand Up @@ -778,6 +782,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-quick-crypto"
react-native-randombytes:
:path: "../node_modules/react-native-randombytes"
react-native-release-profiler:
:path: "../node_modules/react-native-release-profiler"
react-native-restart:
:path: "../node_modules/react-native-restart"
react-native-safe-area-context:
Expand Down Expand Up @@ -911,6 +917,7 @@ SPEC CHECKSUMS:
react-native-quick-base64: a5dbe4528f1453e662fcf7351029500b8b63e7bb
react-native-quick-crypto: 455c1b411db006dba1026a30681ececb19180187
react-native-randombytes: 421f1c7d48c0af8dbcd471b0324393ebf8fe7846
react-native-release-profiler: 5cf11f861bdb8f4b90d0cef3b002d82cfa7043ad
react-native-restart: 7595693413fe3ca15893702f2c8306c62a708162
react-native-safe-area-context: 2cd91d532de12acdb0a9cbc8d43ac72a8e4c897c
react-native-skia: a395bbbb438d593e525f65d0886c36d1c30f0604
Expand Down
176 changes: 88 additions & 88 deletions ios/bitkit.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
"react-native-randombytes": "3.6.1",
"react-native-reanimated": "3.6.1",
"react-native-reanimated-carousel": "3.5.1",
"react-native-release-profiler": "^0.1.6",
"react-native-restart": "0.0.27",
"react-native-safe-area-context": "4.7.4",
"react-native-screens": "3.27.0",
Expand Down
53 changes: 36 additions & 17 deletions src/screens/Settings/DevSettings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import RNFS, { unlink, writeFile } from 'react-native-fs';
import AsyncStorage from '@react-native-async-storage/async-storage';
import Share from 'react-native-share';
import { useTranslation } from 'react-i18next';
import { startProfiling, stopProfiling } from 'react-native-release-profiler';

import { __DISABLE_SLASHTAGS__ } from '../../../constants/env';
import actions from '../../../store/actions/actions';
Expand Down Expand Up @@ -47,6 +48,7 @@ import { getFakeTransaction } from '../../../utils/wallet/testing';
import { createDefaultLdkAccount, setupLdk } from '../../../utils/lightning';
import Dialog from '../../../components/Dialog';
import { resetBackupState } from '../../../store/slices/backup';
import { updateUi } from '../../../store/slices/ui';

const DevSettings = ({
navigation,
Expand All @@ -59,6 +61,7 @@ const DevSettings = ({
const selectedNetwork = useAppSelector(selectedNetworkSelector);
const addressType = useAppSelector(addressTypeSelector);
const accountVersion = useAppSelector(accountVersionSelector);
const isProfiling = useAppSelector((state) => state.ui.isProfiling);
const warnings = useAppSelector((state) => {
return warningsSelector(state, selectedWallet, selectedNetwork);
});
Expand Down Expand Up @@ -135,6 +138,39 @@ const DevSettings = ({
{
title: 'Debug',
data: [
{
title: isProfiling ? 'Stop Profiler' : 'Start Profiler',
type: EItemType.button,
value: isProfiling,
loading: isProfiling,
onPress: async (): Promise<void> => {
if (isProfiling) {
const path = await stopProfiling(true);
dispatch(updateUi({ isProfiling: false }));
console.log('profile file: ', path);
} else {
dispatch(updateUi({ isProfiling: true }));
startProfiling();
}
},
},
{
title: 'Inject Fake Transaction',
type: EItemType.button,
testID: 'InjectFakeTransaction',
onPress: (): void => {
const id =
'9c0bed5b4c0833824210d29c3c847f47132c03f231ef8df228862132b3a8d80a';
const fakeTx = getFakeTransaction(id);
fakeTx[id].height = 0;
injectFakeTransaction({
selectedWallet,
selectedNetwork,
fakeTx,
});
refreshWallet({ selectedWallet, selectedNetwork }).then();
},
},
{
title: 'Trigger exception in React render',
type: EItemType.button,
Expand Down Expand Up @@ -190,23 +226,6 @@ const DevSettings = ({
runChecks({ selectedWallet, selectedNetwork }).then();
},
},
{
title: 'Inject Fake Transaction',
type: EItemType.button,
testID: 'InjectFakeTransaction',
onPress: (): void => {
const id =
'9c0bed5b4c0833824210d29c3c847f47132c03f231ef8df228862132b3a8d80a';
const fakeTx = getFakeTransaction(id);
fakeTx[id].height = 0;
injectFakeTransaction({
selectedWallet,
selectedNetwork,
fakeTx,
});
refreshWallet({ selectedWallet, selectedNetwork }).then();
},
},
],
},
{
Expand Down
1 change: 1 addition & 0 deletions src/store/shapes/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const initialUiState: TUiState = {
isConnectedToElectrum: true,
isOnline: true,
isLDKReady: false, // LDK node running and connected
isProfiling: false,
language: 'en',
profileLink: { title: '', url: '' },
timeZone: 'UTC',
Expand Down
1 change: 1 addition & 0 deletions src/store/types/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export type TUiState = {
isConnectedToElectrum: boolean;
isOnline: boolean;
isLDKReady: boolean;
isProfiling: boolean;
profileLink: TProfileLink;
viewControllers: TUiViewController;
timeZone: string;
Expand Down
Loading
Loading