mirror of https://github.com/keeweb/keeweb.git
displaying fetch time
This commit is contained in:
parent
95239fb257
commit
7f4a7f05f5
|
@ -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)" />
|
||||
|
|
|
@ -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 };
|
||||
|
|
Loading…
Reference in New Issue