Skip to content

Commit

Permalink
Profiler tooltip shows self duration (#18510)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn authored Apr 6, 2020
1 parent c781156 commit 3498f13
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
}

.CurrentCommit {
margin-top: 0.25rem;
margin: 0.25rem 0;
display: block;
width: 100%;
text-align: left;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import * as React from 'react';
import {Fragment, useContext} from 'react';
import {ProfilerContext} from './ProfilerContext';
import {formatDuration, formatTime} from './utils';
import {formatDuration} from './utils';
import WhatChanged from './WhatChanged';
import {StoreContext} from '../context';

Expand Down Expand Up @@ -44,18 +44,17 @@ export default function HoveredFiberInfo({fiberData}: Props) {
for (i = 0; i < commitIndices.length; i++) {
const commitIndex = commitIndices[i];
if (selectedCommitIndex === commitIndex) {
const {duration, timestamp} = profilerStore.getCommitData(
((rootID: any): number),
commitIndex,
);
const {
fiberActualDurations,
fiberSelfDurations,
} = profilerStore.getCommitData(((rootID: any): number), commitIndex);
const actualDuration = fiberActualDurations.get(id) || 0;
const selfDuration = fiberSelfDurations.get(id) || 0;

renderDurationInfo = (
<Fragment>
<label className={styles.Label}>Rendered at:</label>
<div key={commitIndex} className={styles.CurrentCommit}>
{formatTime(timestamp)}s for {formatDuration(duration)}ms
</div>
</Fragment>
<div key={commitIndex} className={styles.CurrentCommit}>
{formatDuration(selfDuration)}ms of {formatDuration(actualDuration)}ms
</div>
);

break;
Expand All @@ -68,10 +67,10 @@ export default function HoveredFiberInfo({fiberData}: Props) {
<div className={styles.Component}>{name}</div>
</div>
<div className={styles.Content}>
<WhatChanged fiberID={((id: any): number)} />
{renderDurationInfo || (
<div>Did not render during this profiling session.</div>
)}
<WhatChanged fiberID={((id: any): number)} />
</div>
</Fragment>
);
Expand Down

0 comments on commit 3498f13

Please sign in to comment.