Files
flipper/desktop/plugins/public/ui-debugger/components/PerfStats.tsx
Luke De Feo d3df6bc00e Attempt to render txid as date if possible
Summary: We are using frame time on android so make sense to present it

Reviewed By: lblasa

Differential Revision: D42996555

fbshipit-source-id: 595a08571ccd82de0761cfeea8a204e576981ee0
2023-02-06 04:33:11 -08:00

98 lines
2.3 KiB
TypeScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import {PerfStatsEvent} from '../types';
import React from 'react';
import {DataSource, DataTable, DataTableColumn} from 'flipper-plugin';
export function PerfStats(props: {events: DataSource<PerfStatsEvent, number>}) {
return (
<DataTable<PerfStatsEvent> dataSource={props.events} columns={columns} />
);
}
function formatDiff(start: number, end: number): string {
const ms = end - start;
return `${ms.toFixed(0)}ms`;
}
const columns: DataTableColumn<PerfStatsEvent>[] = [
{
key: 'txId',
title: 'TXID',
onRender: (row: PerfStatsEvent) => {
try {
return new Date(row.txId).toISOString();
} catch {
return row.txId;
}
},
},
{
key: 'observerType',
title: 'Type',
},
{
key: 'nodesCount',
title: 'Total nodes',
},
{
key: 'start',
title: 'Start',
onRender: (row: PerfStatsEvent) => {
return new Date(row.start).toISOString();
},
},
{
key: 'traversalComplete',
title: 'Traversal time (Main thread)',
onRender: (row: PerfStatsEvent) => {
return formatDiff(row.start, row.traversalComplete);
},
},
{
key: 'snapshotComplete',
title: 'Snapshot time (Main thread)',
onRender: (row: PerfStatsEvent) => {
return formatDiff(row.traversalComplete, row.snapshotComplete);
},
},
{
key: 'queuingComplete',
title: 'Queuing time',
onRender: (row: PerfStatsEvent) => {
return formatDiff(row.snapshotComplete, row.queuingComplete);
},
},
{
key: 'deferredComputationComplete',
title: 'Deferred processing time',
onRender: (row: PerfStatsEvent) => {
return formatDiff(row.queuingComplete, row.deferredComputationComplete);
},
},
{
key: 'serializationComplete',
title: 'Serialization time',
onRender: (row: PerfStatsEvent) => {
return formatDiff(
row.deferredComputationComplete,
row.serializationComplete,
);
},
},
{
key: 'socketComplete',
title: 'Socket send time',
onRender: (row: PerfStatsEvent) => {
return formatDiff(row.serializationComplete, row.socketComplete);
},
},
];