Skip to content

Commit

Permalink
Remove error-prone wall time
Browse files Browse the repository at this point in the history
  • Loading branch information
agg23 committed Dec 19, 2024
1 parent 4bdd625 commit 50c6ea3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
11 changes: 3 additions & 8 deletions packages/trace-viewer/src/ui/callTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,19 @@ import type { ActionTraceEventInContext } from './modelUtil';

export const CallTab: React.FunctionComponent<{
action: ActionTraceEventInContext | undefined,
executionStartTime: number,
executionStartWallTime: number,
startTimeOffset: number,
sdkLanguage: Language | undefined,
}> = ({ action, executionStartTime, executionStartWallTime, sdkLanguage }) => {
}> = ({ action, startTimeOffset, sdkLanguage }) => {
// We never need the waitForEventInfo (`info`).
const paramKeys = React.useMemo(() => Object.keys(action?.params ?? {}).filter(name => name !== 'info'), [action]);

if (!action)
return <PlaceholderPanel text='No action selected' />;

// Calculate execution time relative to the test runner's start time
const startTimeMillis = action.startTime - executionStartTime;
const startTimeMillis = action.startTime - startTimeOffset;
const startTime = msToString(startTimeMillis);

const wallTimeMillis = startTimeMillis + executionStartWallTime;
const wallTime = new Date(wallTimeMillis).toLocaleString(undefined, { timeZoneName: 'short' });

const duration = action.endTime ? msToString(action.endTime - action.startTime) : 'Timed Out';

return (
Expand All @@ -52,7 +48,6 @@ export const CallTab: React.FunctionComponent<{
{
<>
<div className='call-section'>Time</div>
<DateTimeCallLine name='wall time:' value={wallTime} />
<DateTimeCallLine name='start:' value={startTime} />
<DateTimeCallLine name='duration:' value={duration} />
</>
Expand Down
3 changes: 0 additions & 3 deletions packages/trace-viewer/src/ui/networkResourceDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ const RequestTab: React.FunctionComponent<{
}> = ({ resource, sdkLanguage, startTimeOffset }) => {
const [requestBody, setRequestBody] = React.useState<{ text: string, mimeType?: string } | null>(null);

const wallTimeString = React.useMemo(() => resource.startedDateTime.length > 0 ? new Date(resource.startedDateTime).toLocaleString(undefined, { timeZoneName: 'short' }) : '-', [resource.startedDateTime]);

React.useEffect(() => {
const readResources = async () => {
if (resource.request.postData) {
Expand Down Expand Up @@ -102,7 +100,6 @@ const RequestTab: React.FunctionComponent<{
<div className='network-request-details-header'>Request Headers</div>
<div className='network-request-details-headers'>{resource.request.headers.map(pair => `${pair.name}: ${pair.value}`).join('\n')}</div>
<div className='network-request-details-header'>Time</div>
<div className='network-request-details-general'>{`Wall Time: ${wallTimeString}`}</div>
<div className='network-request-details-general'>{`Start: ${msToString(startTimeOffset)}`}</div>
<div className='network-request-details-general'>{`Duration: ${msToString(resource.time)}`}</div>

Expand Down
2 changes: 1 addition & 1 deletion packages/trace-viewer/src/ui/workbench.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export const Workbench: React.FunctionComponent<{
const callTab: TabbedPaneTabModel = {
id: 'call',
title: 'Call',
render: () => <CallTab action={activeAction} executionStartTime={model?.startTime ?? 0} executionStartWallTime={model?.wallTime ?? 0} sdkLanguage={sdkLanguage} />
render: () => <CallTab action={activeAction} startTimeOffset={model?.startTime ?? 0} sdkLanguage={sdkLanguage} />
};
const logTab: TabbedPaneTabModel = {
id: 'log',
Expand Down

0 comments on commit 50c6ea3

Please sign in to comment.