Skip to content

Commit 6ea427c

Browse files
committed
Add Duration/Size columns to the header of view-event list.
1 parent 0eaff10 commit 6ea427c

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

Diff for: src/components/view/view-event-list.tsx

+36-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ import {
2323
} from '../../model/events/categorization';
2424

2525
import { UnreachableCheck } from '../../util/error';
26-
import { getReadableSize } from '../../model/events/bodies';
26+
import {
27+
getReadableSize,
28+
sigFig
29+
} from '../../model/events/bodies';
30+
2731
import { filterProps } from '../component-utils';
2832

2933
import { EmptyState } from '../common/empty-state';
@@ -166,6 +170,18 @@ const PathAndQuery = styled(Column)`
166170
flex-basis: 1000px;
167171
`;
168172

173+
const Duration = styled(Column)`
174+
flex-basis: 80px;
175+
flex-shrink: 0;
176+
flex-grow: 0;
177+
`;
178+
179+
const Size = styled(Column)`
180+
flex-basis: 80px;
181+
flex-shrink: 0;
182+
flex-grow: 0;
183+
`;
184+
169185
// Match Method + Status, but shrink right margin slightly so that
170186
// spinner + "WebRTC Media" fits OK.
171187
const EventTypeColumn = styled(Column)`
@@ -372,6 +388,10 @@ const ExchangeRow = observer(({
372388
category
373389
} = exchange;
374390

391+
let durationMs = ('startTime' in exchange.timingEvents) ? (
392+
(exchange.timingEvents.responseSentTimestamp || exchange.timingEvents.abortedTimestamp || 0) - exchange.timingEvents.startTimestamp
393+
) : 0;
394+
375395
return <TrafficEventListRow
376396
role="row"
377397
aria-label='row'
@@ -420,6 +440,18 @@ const ExchangeRow = observer(({
420440
<PathAndQuery title={ request.parsedUrl.pathname + request.parsedUrl.search }>
421441
{ request.parsedUrl.pathname + request.parsedUrl.search }
422442
</PathAndQuery>
443+
<Duration>
444+
{durationMs > 0
445+
? (
446+
(durationMs < 100) ?
447+
(sigFig(durationMs, 2) + 'ms') :
448+
(durationMs < 1000 ? sigFig(durationMs, 1) + 'ms' : (durationMs < 10000 ? sigFig(durationMs / 1000, 3) + ' s' : sigFig(durationMs / 1000, 1) + ' s'))
449+
)
450+
: ''}
451+
</Duration>
452+
<Size>
453+
{ exchange.isSuccessfulExchange() ? getReadableSize(exchange.response.body.encoded.byteLength) : ''}
454+
</Size>
423455
</TrafficEventListRow>;
424456
});
425457

@@ -666,6 +698,8 @@ export class ViewEventList extends React.Component<ViewEventListProps> {
666698
<Source>Source</Source>
667699
<Host>Host</Host>
668700
<PathAndQuery>Path and query</PathAndQuery>
701+
<Duration>Duration</Duration>
702+
<Size>Size</Size>
669703
</TableHeader>
670704

671705
{
@@ -869,4 +903,4 @@ export class ViewEventList extends React.Component<ViewEventListProps> {
869903

870904
event.preventDefault();
871905
}
872-
}
906+
}

Diff for: src/model/events/bodies.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ export function getReadableSize(bytes: number, siUnits = true) {
1818
return (bytes / Math.pow(thresh, unitIndex)).toFixed(1).replace(/\.0$/, '') + ' ' + unitName;
1919
}
2020

21+
export function sigFig(num: number, figs: number): number {
22+
return parseFloat(num.toFixed(figs));
23+
}
24+
2125
const EncodedSizesCacheKey = Symbol('encoded-body-test');
2226
type EncodedBodySizes = { [encoding: string]: number };
2327
type EncodedSizesCache = Map<typeof EncodedSizesCacheKey,
@@ -45,4 +49,4 @@ export function testEncodings(message: ExchangeMessage): EncodedBodySizes | unde
4549
// Will be undefined, but ensures we're subscribed to the observable
4650
return sizesObservable.get();
4751
}
48-
}
52+
}

0 commit comments

Comments
 (0)