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

This comment has been minimized.

Copy link

commented Feb 17, 2017

Nice job!

@paulirish

This comment has been minimized.

Copy link
Owner Author

commented Apr 19, 2017

:D

image

@paulirish

This comment has been minimized.

Copy link
Owner Author

commented Feb 6, 2018

updated for the latest version of the spec.

@chkal

This comment has been minimized.

Copy link

commented Mar 11, 2018

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

@chkal

This comment has been minimized.

Copy link

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
You can’t perform that action at this time.