Demo of server timing values. visualized in chrome devtools
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// see for screenshot: | |
// https://twitter.com/paul_irish/status/829090506084749312 | |
const http = require('http'); | |
function requestHandler(request, response) { | |
const headers = { | |
'Server-Timing': ` | |
sql-1;desc="MySQL lookup Server";dur=100, | |
sql-2;dur=900;desc="MySQL shard Server #1", | |
fs;dur=600;desc="FileSystem", | |
cache;dur=300;desc="Cache", | |
other;dur=200;desc="Database Write", | |
other;dur=110;desc="Database Read", | |
cpu;dur=1230;desc="Total CPU" | |
`.replace(/\n/g, '') | |
}; | |
response.writeHead(200, headers); | |
response.write(''); | |
return setTimeout(_ => { | |
response.end(); | |
}, 1230) | |
} | |
http.createServer(requestHandler) | |
.listen(8082) | |
.on('error', console.error); |
updated for the latest version of the spec.
Does Chrome implement the latest version of the spec or the format from the original tweet?
Answering my own question: Chrome 65 supports the latest version of the spec (new header format as shows in this gist), Chrome 64 just the old header format.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice job!