displaying fetch time

This commit is contained in:
antelle 2020-03-29 09:55:17 +02:00
parent 95239fb257
commit 7f4a7f05f5
No known key found for this signature in database
GPG Key ID: 094A2F2D6136A4EE
2 changed files with 22 additions and 2 deletions

View File

@ -3,6 +3,9 @@
<head lang="en">
<meta charset="UTF-8" />
<title>KeeWeb</title>
<script>
window.htmlLoadTime = performance.now();
</script>
<meta name="application-name" content="KeeWeb" />
<meta name="kw-signature" content="" />
<meta name="kw-config" content="(no-config)" />

View File

@ -2,9 +2,13 @@ import { Logger } from 'util/logger';
const logger = new Logger('start-profiler');
let lastTs = 0;
const networkTime = getNetworkTime();
let lastTs = window.htmlLoadTime;
const operations = [];
const operations = [
{ name: 'fetching', elapsed: networkTime },
{ name: 'parsing', elapsed: lastTs - networkTime }
];
const StartProfiler = {
milestone(name) {
@ -21,6 +25,19 @@ const StartProfiler = {
}
};
function getNetworkTime() {
let perfEntry;
if (performance.getEntriesByType) {
[perfEntry] = performance.getEntriesByType('navigation');
}
if (!perfEntry || !perfEntry.responseEnd || !perfEntry.fetchStart) {
perfEntry = performance.timing;
}
return perfEntry.responseEnd - perfEntry.fetchStart;
}
StartProfiler.milestone('pre-init');
export { StartProfiler };