-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrowser-json-parse-baseline.js
More file actions
38 lines (32 loc) · 1.1 KB
/
Copy pathbrowser-json-parse-baseline.js
File metadata and controls
38 lines (32 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Initial browser performance baseline for Fast JSON Viewer.
// Run this in Chrome DevTools Console or as a DevTools Snippet.
// Tested source file:
// https://unpkg.com/@mdn/browser-compat-data@8.0.1/data.json
const url = 'https://unpkg.com/@mdn/browser-compat-data@8.0.1/data.json?' + Date.now();
performance.mark("fetch:start");
const res = await fetch(url);
performance.mark("headers:received");
const text = await res.text();
performance.mark("body:received");
const data = JSON.parse(text);
performance.mark("json:parsed");
const pretty = JSON.stringify(data, null, 2);
performance.mark("json:stringified");
console.table([
{
phase: "headers",
ms: performance.measure("headers", "fetch:start", "headers:received").duration,
},
{
phase: "body download + decode",
ms: performance.measure("body", "headers:received", "body:received").duration,
},
{
phase: "JSON.parse",
ms: performance.measure("parse", "body:received", "json:parsed").duration,
},
{
phase: "JSON.stringify pretty",
ms: performance.measure("stringify", "json:parsed", "json:stringified").duration,
},
]);