chore: add performance logger

This commit is contained in:
李华桥
2023-11-10 00:25:15 +08:00
committed by LongYinan
parent 927a6489f9
commit 09c3a8828f
10 changed files with 79 additions and 3 deletions
@@ -40,6 +40,7 @@ import { WorkspaceHeader } from '../../components/workspace-header';
import { useBlockSuiteMetaHelper } from '../../hooks/affine/use-block-suite-meta-helper';
import { useTrashModalHelper } from '../../hooks/affine/use-trash-modal-helper';
import { useCurrentWorkspace } from '../../hooks/current/use-current-workspace';
import { performanceRenderLogger } from '../../shared';
import * as styles from './all-page.css';
import { EmptyPageList } from './page-list-empty';
import { useFilteredPageMetas } from './pages';
@@ -302,5 +303,7 @@ export const AllPage = () => {
};
export const Component = () => {
performanceRenderLogger.info('AllPage');
return <AllPage />;
};
@@ -29,6 +29,7 @@ import { WorkspaceHeader } from '../../components/workspace-header';
import { useRegisterBlocksuiteEditorCommands } from '../../hooks/affine/use-register-blocksuite-editor-commands';
import { useCurrentWorkspace } from '../../hooks/current/use-current-workspace';
import { useNavigateHelper } from '../../hooks/use-navigate-helper';
import { performanceRenderLogger } from '../../shared';
const DetailPageImpl = (): ReactElement => {
const { openPage, jumpToSubPath } = useNavigateHelper();
@@ -145,5 +146,7 @@ export const loader: LoaderFunction = async args => {
};
export const Component = () => {
performanceRenderLogger.info('DetailPage');
return <DetailPage />;
};
@@ -15,10 +15,17 @@ import {
} from 'react-router-dom';
import { WorkspaceLayout } from '../../layouts/workspace-layout';
import { performanceLogger, performanceRenderLogger } from '../../shared';
const workspaceLoaderLogger = performanceLogger.namespace('workspace_loader');
export const loader: LoaderFunction = async args => {
workspaceLoaderLogger.info('start');
const rootStore = getCurrentStore();
const meta = await rootStore.get(rootWorkspacesMetadataAtom);
workspaceLoaderLogger.info('meta loaded');
const currentMetadata = meta.find(({ id }) => id === args.params.workspaceId);
if (!currentMetadata) {
return redirect('/404');
@@ -32,6 +39,8 @@ export const loader: LoaderFunction = async args => {
}
if (currentMetadata.flavour === WorkspaceFlavour.AFFINE_CLOUD) {
const [workspaceAtom] = getBlockSuiteWorkspaceAtom(currentMetadata.id);
workspaceLoaderLogger.info('get cloud workspace atom');
const workspace = await rootStore.get(workspaceAtom);
return (() => {
const blockVersions = workspace.meta.blockVersions;
@@ -46,10 +55,14 @@ export const loader: LoaderFunction = async args => {
return false;
})();
}
workspaceLoaderLogger.info('done');
return null;
};
export const Component = (): ReactElement => {
performanceRenderLogger.info('WorkspaceLayout');
const incompatible = useLoaderData();
return (
<WorkspaceLayout incompatible={!!incompatible}>