Improve table view

Summary:
added component name, root component name, duration, event type and better names

changelog: UIDebugger - added event debugger table view and side panel views

Reviewed By: lblasa

Differential Revision: D48559367

fbshipit-source-id: d357ecf654b4e443eac7673731a8be542e76dd48
This commit is contained in:
Luke De Feo
2023-08-23 01:51:31 -07:00
committed by Facebook GitHub Bot
parent 5f9000aa82
commit 206ef79cf9
8 changed files with 112 additions and 45 deletions

View File

@@ -0,0 +1,33 @@
/**
* 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 {options} from '../components/sidebar/inspector/FrameworkEventsInspector';
export function formatTimestampMillis(timestamp: number): string {
const date = new Date(timestamp);
const formattedDate = new Intl.DateTimeFormat('en-US', options).format(date);
const milliseconds = date.getMilliseconds();
return `${formattedDate}.${milliseconds.toString().padStart(3, '0')}`;
}
export function formatDuration(nanoseconds: number): string {
if (nanoseconds < 1_000) {
return `${nanoseconds} nanoseconds`;
} else if (nanoseconds < 1_000_000) {
return `${(nanoseconds / 1_000).toFixed(2)} microseconds`;
} else if (nanoseconds < 1_000_000_000) {
return `${(nanoseconds / 1_000_000).toFixed(2)} milliseconds`;
} else if (nanoseconds < 1_000_000_000_000) {
return `${(nanoseconds / 1_000_000_000).toFixed(2)} seconds`;
} else {
return `${(nanoseconds / (1_000_000_000 * 60)).toFixed(2)} minutes`;
}
}