mirror of
https://github.com/TangentFoxy/memex.git
synced 2024-12-17 19:14:21 +00:00
Refactor benchmarking.
This commit is contained in:
parent
eea38f4cc1
commit
2f8809cafb
@ -9,13 +9,20 @@
|
||||
<body>
|
||||
<script> let theme = new Theme(); theme.install(); theme.start(); </script>
|
||||
<div class="loading-wave"><div></div><div></div><div></div><div></div><div></div></div>
|
||||
<div class="error"></div>
|
||||
|
||||
<nav></nav>
|
||||
<div class="container">
|
||||
<main></main>
|
||||
</div>
|
||||
|
||||
<!-- everything above here is for initial load (display pretty loading anim ASAP) -->
|
||||
|
||||
<script src="logic/main.js"></script>
|
||||
<script>
|
||||
var main = new Main(); // starts benchmark timing
|
||||
</script>
|
||||
|
||||
<div class="error"></div>
|
||||
<div class="lightbox"></div>
|
||||
<div class="page-overlay"></div>
|
||||
|
||||
@ -30,7 +37,6 @@
|
||||
<script src="logic/view/grid.js"></script>
|
||||
<script src="logic/view/nav.js"></script>
|
||||
<script src="logic/wrap.js"></script>
|
||||
<script src="logic/main.js"></script>
|
||||
<script src="logic/add.js"></script>
|
||||
<script src="logic/lightbox.js"></script>
|
||||
<script>
|
||||
@ -42,7 +48,6 @@
|
||||
let lightbox = new Lightbox;
|
||||
lightbox.install(document.querySelector('.lightbox'), 'lightbox');
|
||||
|
||||
var main = new Main();
|
||||
main.install();
|
||||
main.start();
|
||||
|
||||
|
@ -11,6 +11,7 @@ function Main()
|
||||
this.queryPrev = '';
|
||||
this.queryPrevAdd = '';
|
||||
|
||||
this.timeBegin = Date.now();
|
||||
this.timeStore = Date.now();
|
||||
this.curTime = null;
|
||||
|
||||
@ -51,7 +52,7 @@ function Main()
|
||||
|
||||
this.start = function()
|
||||
{
|
||||
this.timediff('call start');
|
||||
this.timediff('load all js files');
|
||||
this.database.start(new Indental(DATABASE).parse())
|
||||
.then((db) => {
|
||||
this.timediff('process db');
|
||||
@ -61,6 +62,7 @@ function Main()
|
||||
this.timediff('build html');
|
||||
document.querySelector('main').innerHTML = html;
|
||||
this.timediff('render html');
|
||||
console.log('TOTAL: ' + (Date.now() - this.timeBegin) + ' ms');
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('ERROR:', error);
|
||||
@ -100,43 +102,6 @@ function Main()
|
||||
}
|
||||
else
|
||||
{
|
||||
// this.db.filter(this.queryCur)
|
||||
// .then(function(results){
|
||||
// // Map our array of entries to
|
||||
// // an array of template promises.
|
||||
// // This makes sure they all template in parallel.
|
||||
// return results.map(this.grid.templateEntry)
|
||||
// .reduce(function(sequence, chapterPromise) {
|
||||
// // Use reduce to chain the promises together,
|
||||
// // adding content to the page for each entry
|
||||
// return sequence.then(function() {
|
||||
// // Wait for everything in the sequence so far,
|
||||
// // then wait for this template to arrive.
|
||||
// return chapterPromise;
|
||||
// }).then(function(article) {
|
||||
// this.grid.addHtmlToPage(article.html);
|
||||
// });
|
||||
// }, Promise.resolve());
|
||||
// })
|
||||
// .then(function() { console.log("done"); })
|
||||
// .catch(function(err) { console.log("error: " + err.message); });
|
||||
// .then(function() { console.log("stop loading anim"); })
|
||||
|
||||
// see: https://developers.google.com/web/fundamentals/primers/promises#whats-all-the-fuss-about
|
||||
|
||||
// this.db.filter(this.queryCur)
|
||||
// .then(function(results){
|
||||
// return this.grid.templateEntry(results[0]);
|
||||
// }).then(function(article) {
|
||||
// this.grid.addHtmlToPage(article.html);
|
||||
// }).catch(function() {
|
||||
// console.log("error: " + err.message);
|
||||
// }).then(function() {
|
||||
// console.log("stop loading anim");
|
||||
// })
|
||||
|
||||
// see: https://developers.google.com/web/fundamentals/primers/promises#whats-all-the-fuss-about
|
||||
|
||||
this.grid.display(this.db.filter(this.queryCur));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user