Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Demo of server timing values. visualized in chrome devtools
// 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);
@brandonsturgeon
Copy link

brandonsturgeon commented Feb 17, 2017

Nice job!

@paulirish
Copy link
Author

paulirish commented Apr 19, 2017

:D

image

@paulirish
Copy link
Author

paulirish commented Feb 6, 2018

updated for the latest version of the spec.

@chkal
Copy link

chkal commented Mar 11, 2018

Does Chrome implement the latest version of the spec or the format from the original tweet?

@chkal
Copy link

chkal commented Mar 11, 2018

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