Skip to content

Instantly share code, notes, and snippets.

@klinkby
Created September 28, 2017 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klinkby/774c1422ff6289fdcd4b1f3528f2a024 to your computer and use it in GitHub Desktop.
Save klinkby/774c1422ff6289fdcd4b1f3528f2a024 to your computer and use it in GitHub Desktop.
Collect key performance metrics, dump in document then reload page for another run.
(function () {
"use strict";
var t = performance.timing,
t1 = t.navigationStart,
arr = [t.responseEnd - t1, t.domContentLoadedEventStart - t1, t.loadEventEnd - t1],
storage = sessionStorage,
storageKey = "perf-coll",
coll = JSON.parse(storage.getItem(storageKey) || "[]"),
serialized;
coll.push(arr);
serialized = JSON.stringify(coll)
storage.setItem(storageKey, serialized);
document.body.textContent = serialized;
console.info(coll.length);
setTimeout(function () {
location.reload();
}, 2000);
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment