diff --git a/docs/index.html b/docs/index.html index 69742c6..11e77a9 100644 --- a/docs/index.html +++ b/docs/index.html @@ -17,10 +17,10 @@ - +
diff --git a/docs/logic/main.js b/docs/logic/main.js index 4457f76..4746821 100644 --- a/docs/logic/main.js +++ b/docs/logic/main.js @@ -14,7 +14,7 @@ function Main() this.install = function() { - benchmark.note('load all js files'); + seer.note('load all js files'); this.util = new Util(); this.database = new Wrap(); @@ -39,7 +39,7 @@ function Main() // } } - benchmark.note('install main'); + seer.note('install main'); } this.resetPage = function() @@ -67,31 +67,31 @@ function Main() { this.database.start() .then((db) => { - benchmark.note('process db'); + seer.note('process db'); this.resetPage(); this.updateQuery(); - benchmark.note('prep query'); + seer.note('prep query'); return this.database.filter(db, this.queryCur); }) .then((filtered) => { - benchmark.note('filter db'); + seer.note('filter db'); return this.grid.buildAllArticles(filtered); }) .then((html) => { - benchmark.note('build html'); + seer.note('build html'); let stats = this.database.stats(); - benchmark.note('calc stats'); + seer.note('calc stats'); this.nav.display(stats); - benchmark.note('render stats'); + seer.note('render stats'); this.grid.newDisplay(html); - // benchmark.note('render html'); + // seer.note('render html'); - benchmark.complete(); + seer.report(); document.querySelector('.loading-wave').style.display = 'none'; }) @@ -102,6 +102,11 @@ function Main() // } + this.load = function() + { + + } + // this.load = function(target) // { // lightbox.close(); diff --git a/docs/logic/mark.js b/docs/logic/mark.js deleted file mode 100644 index f76e705..0000000 --- a/docs/logic/mark.js +++ /dev/null @@ -1,38 +0,0 @@ -function Mark() -{ - this.timeBegin = null; - this.timeStore = null; - this.curTime = null; - this.specialDesc = null; - this.specialTime = null; - - this.install = function() - { - this.timeBegin = Date.now(); - this.timeStore = Date.now(); - } - - this.note = function(desc) - { - this.curTime = Date.now(); - console.log((this.curTime - this.timeStore) + ' ms to ' + desc); - this.timeStore = this.curTime; - } - - this.special = function(desc) - { - this.specialDesc = desc; - this.specialTime = Date.now() - this.timeStore; - this.note(desc); - } - - this.complete = function() - { - let total = (Date.now() - this.timeBegin); - console.log('TOTAL TIME: ' + total + ' ms'); - if (this.specialDesc != null) - { - console.log(((this.specialTime / total)*100).toFixed(0) + ' % of time spent on: ' + this.specialDesc); - } - } -} \ No newline at end of file diff --git a/docs/logic/seer.js b/docs/logic/seer.js new file mode 100644 index 0000000..82e0e3e --- /dev/null +++ b/docs/logic/seer.js @@ -0,0 +1,48 @@ +"use strict"; +function Seer() +{ + this.verbose = false + this.quota = 0; + + this.timeBegin = null; + this.timeRef = null; + this.book = null; + + this.install = function(verbose, quota) + { + this.verbose = verbose; + this.quota = quota; + this.timeBegin = Date.now(); + this.timeRef = Date.now(); + this.book = []; + } + + this.note = function(desc) + { + var entry = [desc, (Date.now() - this.timeRef)]; + this.book.push(entry); + if (this.verbose) + { + console.log(entry[1] + ' ms to ' + entry[0]); + } + this.timeRef = Date.now(); + } + + this.report = function() + { + let total = (Date.now() - this.timeBegin); + console.log('Completed in: ' + total + ' ms'); + if (this.quota > 0) + { + this.book.sort(function(a, b) + { + return a[1] + b[1]; + }); + for (var i = 0; i < Math.min(this.quota, this.book.length); i++) + { + let percentage = ((this.book[i][1] / total) * 100).toFixed(1); + console.log(percentage + ' % of time spent on: ' + this.book[i][0]); + } + } + } +} \ No newline at end of file diff --git a/docs/logic/view/grid.js b/docs/logic/view/grid.js index 7f1ea94..199e4e2 100644 --- a/docs/logic/view/grid.js +++ b/docs/logic/view/grid.js @@ -33,7 +33,7 @@ function Grid() document.querySelector('main').innerHTML = html; - benchmark.note('render html'); + seer.note('render html'); // LAYOUT if (SETTINGS.USEMASONRY) @@ -56,7 +56,7 @@ function Grid() } } - benchmark.special('masonry layout'); + seer.note('masonry layout'); } }