Show a breakdown of timing.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3797 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
9fd4be0e4a
commit
e4d77679dc
@ -1 +1 @@
|
|||||||
{"type":"tildefriends-app","files":{"app.js":"&MctA7OZPTgdTZnlSwKMJTYjZg+S8blg4VdO/njxN0QU=.sha256","index.html":"&eY9aBHpnmbMTXXnbzv9gxxXvJp8O5NpcqulQxdnsW/s=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&DdJwZYEo7AqFyutYMvEjykoVXxdHVog0UXye6Sbo0TU=.sha256","tf-message.js":"&3dPiSNYjoJE3zn1oTT1SBhbvkW9MHr7ZUDxUJiBI1Ss=.sha256","tf.js":"&7hS4IikdZdlZDiMlZ1UK9Wf6rdOwceevKGPBRlhDZ68=.sha256","commonmark.min.js":"&EP0OeR9zyLwZannz+0ga4s9AGES2RLvvIIQYHqqV6+k=.sha256","vue.js":"&g1wvA+yHl1sVC+eufTsg9If7ZeVyMTBU+h0tks7ZNzE=.sha256","vue-material-theme-default-dark.css":"&RP2nr+2CR18BpHHw5ST9a5GJUCOG9n0G2kuGkcQioWE=.sha256","vue-material.min.css":"&kGbUM2QgFSyHZRzqQb0b+0S3EVIlZ0AXpdiAVjIhou8=.sha256","roboto.css":"&jJv43Om673mQO5JK0jj7714s5E+5Yrf82H6LcDx7wUs=.sha256","material-icons.css":"&a28PdcVvgq/DxyIvJAx/e+ZOEtOuHnr3kjLWKyzH11M=.sha256","tf-shared.js":"&+qPP3g4CAUlkt8K4iBCZ+F5Fy6N7fu6MggvSVss2juE=.sha256"}}
|
{"type":"tildefriends-app","files":{"app.js":"&mDHhPk+YJm9K32UmO6WNUoJGM1tX4Dx7GIMjLvyurXg=.sha256","index.html":"&WJSszNEPd6ypJkfTUu/YHSDvU8VZrAHvyRmzNoZBPb0=.sha256","vue-material.js":"&K5cdLqXYCENPak/TCINHQhyJhpS4G9DlZHGwoh/LF2g=.sha256","tf-user.js":"&DdJwZYEo7AqFyutYMvEjykoVXxdHVog0UXye6Sbo0TU=.sha256","tf-message.js":"&3dPiSNYjoJE3zn1oTT1SBhbvkW9MHr7ZUDxUJiBI1Ss=.sha256","tf.js":"&DQtOS/nh5/a6QlqNrIb5Zi3Bz4pn3MBe5peRkwLZuyA=.sha256","commonmark.min.js":"&EP0OeR9zyLwZannz+0ga4s9AGES2RLvvIIQYHqqV6+k=.sha256","vue.js":"&g1wvA+yHl1sVC+eufTsg9If7ZeVyMTBU+h0tks7ZNzE=.sha256","vue-material-theme-default-dark.css":"&RP2nr+2CR18BpHHw5ST9a5GJUCOG9n0G2kuGkcQioWE=.sha256","vue-material.min.css":"&kGbUM2QgFSyHZRzqQb0b+0S3EVIlZ0AXpdiAVjIhou8=.sha256","roboto.css":"&jJv43Om673mQO5JK0jj7714s5E+5Yrf82H6LcDx7wUs=.sha256","material-icons.css":"&a28PdcVvgq/DxyIvJAx/e+ZOEtOuHnr3kjLWKyzH11M=.sha256","tf-shared.js":"&+qPP3g4CAUlkt8K4iBCZ+F5Fy6N7fu6MggvSVss2juE=.sha256"}}
|
@ -305,13 +305,17 @@ core.register('onConnectionsChanged', async function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
async function refresh(selected) {
|
async function refresh(selected) {
|
||||||
|
var timing = [];
|
||||||
|
timing.push({name: 'start', time: new Date()});
|
||||||
g_following_cache = {};
|
g_following_cache = {};
|
||||||
g_followers_cache = {};
|
g_followers_cache = {};
|
||||||
g_following_deep_cache = {};
|
g_following_deep_cache = {};
|
||||||
await app.postMessage({clear: true});
|
await app.postMessage({clear: true});
|
||||||
var whoami = await ssb.whoami();
|
var whoami = await ssb.whoami();
|
||||||
var db = await database("ssb");
|
var db = await database("ssb");
|
||||||
|
timing.push({name: 'init', time: new Date()});
|
||||||
var all_followed = await followingDeep(db, [whoami], 2);
|
var all_followed = await followingDeep(db, [whoami], 2);
|
||||||
|
timing.push({name: 'all_followed', time: new Date()});
|
||||||
if (selected) {
|
if (selected) {
|
||||||
g_selected = selected;
|
g_selected = selected;
|
||||||
} else {
|
} else {
|
||||||
@ -324,6 +328,7 @@ async function refresh(selected) {
|
|||||||
ssb.connections().then(connections => app.postMessage({connections: connections})),
|
ssb.connections().then(connections => app.postMessage({connections: connections})),
|
||||||
core.apps().then(apps => app.postMessage({apps: apps})),
|
core.apps().then(apps => app.postMessage({apps: apps})),
|
||||||
]);
|
]);
|
||||||
|
timing.push({name: 'core', time: new Date()});
|
||||||
var ids;
|
var ids;
|
||||||
if (selected && selected.length == 1 && selected[0].startsWith('%')) {
|
if (selected && selected.length == 1 && selected[0].startsWith('%')) {
|
||||||
var m = await getPosts(db, selected);
|
var m = await getPosts(db, selected);
|
||||||
@ -332,7 +337,9 @@ async function refresh(selected) {
|
|||||||
} else {
|
} else {
|
||||||
ids = await getRecentPostIds(db, whoami, g_selected, k_posts_max);
|
ids = await getRecentPostIds(db, whoami, g_selected, k_posts_max);
|
||||||
}
|
}
|
||||||
|
timing.push({name: 'get_post_ids', time: new Date()});
|
||||||
var posts = await getPosts(db, ids);
|
var posts = await getPosts(db, ids);
|
||||||
|
timing.push({name: 'get_posts', time: new Date()});
|
||||||
var roots = posts.map(function(x) {
|
var roots = posts.map(function(x) {
|
||||||
try {
|
try {
|
||||||
return JSON.parse(x.content).root;
|
return JSON.parse(x.content).root;
|
||||||
@ -343,11 +350,24 @@ async function refresh(selected) {
|
|||||||
var have = new Set(posts.map(x => x.id));
|
var have = new Set(posts.map(x => x.id));
|
||||||
roots = [...new Set(roots)].filter(x => x && !have.has(x));
|
roots = [...new Set(roots)].filter(x => x && !have.has(x));
|
||||||
var all_posts = [].concat(posts, await getPosts(db, roots));
|
var all_posts = [].concat(posts, await getPosts(db, roots));
|
||||||
|
timing.push({name: 'get_root_posts', time: new Date()});
|
||||||
await Promise.all(all_posts.map(x => app.postMessage({message: x})));
|
await Promise.all(all_posts.map(x => app.postMessage({message: x})));
|
||||||
|
timing.push({name: 'send_posts', time: new Date()});
|
||||||
await Promise.all(all_followed.map(id => getAbout(db, id).then(results => app.postMessage({user: {user: id, about: results}}))));
|
await Promise.all(all_followed.map(id => getAbout(db, id).then(results => app.postMessage({user: {user: id, about: results}}))));
|
||||||
|
timing.push({name: 'about', time: new Date()});
|
||||||
await Promise.all(all_followed.map(id => getVotes(db, id).then(results => results.length ? app.postMessage({votes: results}) : null)));
|
await Promise.all(all_followed.map(id => getVotes(db, id).then(results => results.length ? app.postMessage({votes: results}) : null)));
|
||||||
|
timing.push({name: 'votes', time: new Date()});
|
||||||
await Promise.all(all_followed.map(id => following(db, id).then(results => app.postMessage({following: {id: id, users: [...results]}}))));
|
await Promise.all(all_followed.map(id => following(db, id).then(results => app.postMessage({following: {id: id, users: [...results]}}))));
|
||||||
await app.postMessage({ready: true});
|
timing.push({name: 'following', time: new Date()});
|
||||||
|
|
||||||
|
var times = {};
|
||||||
|
var previous = null;
|
||||||
|
for (let t of timing) {
|
||||||
|
times[t.name] = t.time - (previous || t).time;
|
||||||
|
previous = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
await app.postMessage({ready: true, times: times});
|
||||||
}
|
}
|
||||||
|
|
||||||
ssb.addEventListener('message', async function(id) {
|
ssb.addEventListener('message', async function(id) {
|
||||||
|
@ -47,7 +47,12 @@
|
|||||||
</md-app-toolbar>
|
</md-app-toolbar>
|
||||||
<md-app-content>
|
<md-app-content>
|
||||||
Welcome, <tf-user :id="whoami"></tf-user>.
|
Welcome, <tf-user :id="whoami"></tf-user>.
|
||||||
<span v-if="load_time" style="float: right">Loaded in {{load_time}} seconds.</span>
|
<span v-if="load_time" style="float: right">
|
||||||
|
Loaded in {{load_time}} seconds.
|
||||||
|
<md-tooltip v-if="Object.keys(times).length" style="height: auto">
|
||||||
|
<div v-for="key in Object.keys(times)">{{key}}: {{times[key] / 1000.0}} s</div>
|
||||||
|
</md-tooltip>
|
||||||
|
</span>
|
||||||
<md-card class="md-elevation-8">
|
<md-card class="md-elevation-8">
|
||||||
<md-card-header>
|
<md-card-header>
|
||||||
<div class="md-title">What's up?</div>
|
<div class="md-title">What's up?</div>
|
||||||
|
@ -21,6 +21,7 @@ var g_data = {
|
|||||||
edit_profile_description: null,
|
edit_profile_description: null,
|
||||||
load_time: null,
|
load_time: null,
|
||||||
post_text: null,
|
post_text: null,
|
||||||
|
times: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
var g_load_start = new Date();
|
var g_load_start = new Date();
|
||||||
@ -134,6 +135,7 @@ function processMessages() {
|
|||||||
} else if (key == 'ready') {
|
} else if (key == 'ready') {
|
||||||
g_data.load_time = (new Date() - g_load_start) / 1000;
|
g_data.load_time = (new Date() - g_load_start) / 1000;
|
||||||
g_data.loading = false;
|
g_data.loading = false;
|
||||||
|
g_data.times = event.data.times;
|
||||||
} else if (key == 'unread') {
|
} else if (key == 'unread') {
|
||||||
g_data.unread += event.data.unread;
|
g_data.unread += event.data.unread;
|
||||||
} else if (key == 'hash') {
|
} else if (key == 'hash') {
|
||||||
|
Loading…
Reference in New Issue
Block a user