Skip to content

Commit a60ce2a

Browse files
authored
Merge pull request #282 from radum/http2-chunks
Support chunks in HTTP2 Fixes #237
2 parents 9e7ca09 + 1b405ec commit a60ce2a

File tree

6 files changed

+35
-2
lines changed

6 files changed

+35
-2
lines changed

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@
5656
"whatwg-fetch": "^3.6.2"
5757
},
5858
"dependencies": {
59-
"@types/har-format": "^1.2.6"
59+
"@types/har-format": "^1.2.8"
6060
}
6161
}

Diff for: src/css-raw/perf-cascade.css

+1
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
.block-send {fill: #b0bec5;}
133133
.block-wait {fill: #1ec659;}
134134
.block-receive {fill: #1eaaf1;}
135+
.block-receive-chunk {fill: #a1c3fa;}
135136
.block-undefined {fill: #0f0;}
136137

137138
/* Info overlay SVG - wrapper */

Diff for: src/ts/transformers/har.ts

+5
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ const getUserTimings = (currPage: Page, options: ChartOptions) => {
242242
*/
243243
const buildDetailTimingBlocks = (startRelative: number, harEntry: Entry): WaterfallEntryTiming[] => {
244244
const t = harEntry.timings;
245+
const chunks = harEntry._chunks || [];
245246
const types: TimingType[] = ["blocked", "dns", "connect", "send", "wait", "receive"];
246247
return types.reduce((collect: WaterfallEntryTiming[], key: TimingType) => {
247248
const time = getTimePair(key, harEntry, collect, startRelative);
@@ -261,6 +262,10 @@ const buildDetailTimingBlocks = (startRelative: number, harEntry: Entry): Waterf
261262
.concat([createWaterfallEntryTiming(key, Math.round(connectStart), Math.round(time.end))]);
262263
}
263264

265+
if (key === "receive" && chunks && chunks.length > 0) {
266+
return collect.concat([createWaterfallEntryTiming(key, Math.round(time.start), Math.round(time.end), chunks)]);
267+
}
268+
264269
return collect.concat([createWaterfallEntryTiming(key, Math.round(time.start), Math.round(time.end))]);
265270
}, []);
266271
};

Diff for: src/ts/transformers/helpers.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,16 @@ export function createWaterfallEntry(url: string,
106106
/** helper to create a `WaterfallEntryTiming` */
107107
export function createWaterfallEntryTiming(type: TimingType,
108108
start: number,
109-
end: number): WaterfallEntryTiming {
109+
end: number,
110+
chunks?: { bytes: number, ts: number }[]): WaterfallEntryTiming {
110111
const total = (typeof start !== "number" || typeof end !== "number") ? NaN : (end - start);
111112
const typeClean = sanitizeAlphaNumeric(type) as TimingType;
112113
return {
113114
end,
114115
start,
115116
total,
116117
type : typeClean,
118+
chunks,
117119
};
118120
}
119121

Diff for: src/ts/typing/waterfall.ts

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export interface WaterfallEntryTiming {
7777
start: number;
7878
/** end time in ms - relative to initial document request */
7979
end: number;
80+
chunks?: Array<object>;
8081
}
8182

8283
export interface WaterfallResponseDetails {

Diff for: src/ts/waterfall/row/svg-row-subcomponents.ts

+24
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,22 @@ function makeBlock(rectData: RectData, className: string) {
5757
return holder;
5858
}
5959

60+
function makeChunkBlock(chunkData, rectData: RectData, className: string) {
61+
const holder = svg.newG("");
62+
const blockHeight = rectData.height - 1;
63+
// TODO: Once we have a way to pass the available bandwidth we can calculate the length for each chunk.
64+
// const blockWidth = chunkData.ts - (chunkData.bytes / (5000000 / 8.0));
65+
const rectX = misc.roundNumber(chunkData.ts / rectData.unit) + "%";
66+
const rect = svg.newRect({
67+
height: blockHeight,
68+
width: "1px", // misc.roundNumber(blockWidth / rectData.unit) + "%",
69+
x: rectX,
70+
y: rectData.y,
71+
}, className);
72+
holder.appendChild(rect);
73+
return holder;
74+
}
75+
6076
/**
6177
* Converts a segment to RectData
6278
* @param {WaterfallEntryTiming} segment
@@ -142,6 +158,14 @@ export function createRect(rectData: RectData, entry: WaterfallEntry): SVGElemen
142158
const childRectData = segmentToRectData(segment, rectData);
143159
const childRect = makeBlock(childRectData, `segment ${childRectData.cssClass}`);
144160
firstX = Math.min(firstX, childRectData.x);
161+
162+
if (segment.type === 'receive' && segment.chunks && segment.chunks.length > 0) {
163+
segment.chunks.forEach((chunk) => {
164+
const chunkRect = makeChunkBlock(chunk, childRectData, `${childRectData.cssClass}-chunk`);
165+
childRect.appendChild(chunkRect);
166+
});
167+
}
168+
145169
rectHolder.appendChild(childRect);
146170
}
147171
});

0 commit comments

Comments
 (0)