Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix durations in the network panel #1752

Merged
merged 2 commits into from
Feb 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/network-chart/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ function _getVirtualListItems(props: Props): NetworkChartRowProps[] {
};
}
// Compute the positioning of the network markers.
const startPosition = _timeToCssPixels(props, networkPayload.startTime);
const endPosition = _timeToCssPixels(props, networkPayload.endTime);
const startPosition = _timeToCssPixels(props, marker.start);
const endPosition = _timeToCssPixels(props, marker.start + marker.dur);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that all our marker components deal with marker.start/dur instead of looking at the payload, at least for the general things.


// Set min-width for marker bar.
let markerWidth = endPosition - startPosition;
Expand Down
11 changes: 8 additions & 3 deletions src/profile-logic/marker-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type {
IndexIntoStringTable,
} from '../types/profile';
import type { Marker } from '../types/profile-derived';
import type { BailoutPayload } from '../types/markers';
import type { BailoutPayload, NetworkPayload } from '../types/markers';
import type { UniqueStringArray } from '../utils/unique-string-array';
import { getNumberPropertyOrNull } from '../utils/flow';

Expand Down Expand Up @@ -473,9 +473,14 @@ export function mergeStartAndEndNetworkMarker(markers: Marker[]): Marker[] {
marker.data.status === 'STATUS_START'
? [marker, markerNext]
: [markerNext, marker];
const startData: NetworkPayload = (startMarker.data: any);
const endData: NetworkPayload = (endMarker.data: any);
const mergedMarker = {
data: endMarker.data,
dur: endMarker.dur,
data: {
...endData,
startTime: startData.startTime,
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't the end of the road, because we'll want to add a property to represent the startMarker's endTime. I think handling this would fix #1349 too.

but at least we now display the right durations.

dur: startMarker.dur + endMarker.dur,
name: endMarker.name,
title: endMarker.title,
start: startMarker.start,
Expand Down
11 changes: 7 additions & 4 deletions src/test/components/NetworkChart.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ import mockCanvasContext from '../fixtures/mocks/canvas-context';
import { storeWithProfile } from '../fixtures/stores';
import {
getProfileWithMarkers,
getNetworkMarker,
getNetworkMarkers,
} from '../fixtures/profiles/processed-profile';
import { getBoundingBox } from '../fixtures/utils';
import mockRaf from '../fixtures/mocks/request-animation-frame';
import { type NetworkPayload } from '../../types/markers';

const NETWORK_MARKERS = Array(10)
.fill()
.map((_, i) => getNetworkMarker(3 + 0.1 * i, i));
const NETWORK_MARKERS = (function() {
const arrayOfNetworkMarkers = Array(10)
.fill()
.map((_, i) => getNetworkMarkers(3 + 0.1 * i, i));
return [].concat(...arrayOfNetworkMarkers);
})();

function setupWithProfile(profile) {
const flushRafCalls = mockRaf();
Expand Down
Loading