Skip to content

Commit

Permalink
Updated script
Browse files Browse the repository at this point in the history
  • Loading branch information
mmocny committed Nov 24, 2023
1 parent 189a1fd commit 70e52ab
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
4 changes: 4 additions & 0 deletions sandbox/snippets/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

rm -rf dist/
esbuild *.js --bundle --minify $file --outdir=dist
1 change: 0 additions & 1 deletion sandbox/snippets/build/measure-history-events.js

This file was deleted.

1 change: 1 addition & 0 deletions sandbox/snippets/dist/measure-history-events.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 11 additions & 8 deletions sandbox/snippets/measure-history-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,32 @@ function cleanTime(ms) {

// Note: console doesn't work from page lifecycle events.
function logEvent(event) {
const eventName = 'Soft.' + event.type;
const eventName = event.type;

const start = performance.now();
console.log(eventName, ".start", cleanTime(start + performance.timeOrigin));
console.log(eventName, "start", cleanTime(start + performance.timeOrigin));
// localStorage[eventName + ".start"] = cleanTime(start + performance.timeOrigin);

performance.mark(eventName + ".start", { startTime: start });
performance.measure(eventName + ".inputDelay", { start: event.timeStamp, end: start });

block(200);

const end = performance.now();
console.log(eventName, ".end", cleanTime(end + performance.timeOrigin));
console.log(eventName, "end", cleanTime(end + performance.timeOrigin));
// localStorage[eventName + ".end"] = cleanTime(end + performance.timeOrigin);

performance.measure(eventName, { start, end });
performance.measure(eventName + ".processing", { start, end });
}

function oncePerPageLoad() {
if (window.init) return;
window.init = true;
if (window.init_cguhvbj) return;
window.init_cguhvbj = true;

navigation.addEventListener('navigate', logEvent);
document.addEventListener("click", logEvent);
document.addEventListener('visibilitychange', logEvent);

navigation.addEventListener('navigate', logEvent);

window.addEventListener('pagehide', logEvent);
window.addEventListener('pageshow', logEvent);
window.addEventListener("popstate", logEvent);
Expand Down

0 comments on commit 70e52ab

Please sign in to comment.