From e78b32968fe6fdc2494b3d42fbd72848b3fc8b5c Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sat, 5 Oct 2019 14:05:11 +0200 Subject: Optimize performance. A lot of time went by in the `time_f()` function, simplify it by not using the JavaScript date formatting framework which is way overkill. --- public/js/app.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'public') diff --git a/public/js/app.js b/public/js/app.js index f256c84..728f267 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -42,9 +42,12 @@ window.addEventListener("load", function() { s.push(screening) }; - function time_f(t) { - let f = Intl.NumberFormat('nb-NO', { minimumIntegerDigits: 2 }) - return [ f.format(t.getHours()), f.format(t.getMinutes()) ].join(':') + function pad(num) { + return num > 9 ? num.toString() : "0" + num + } + + function time_f(t) { + return pad(t.getHours()) + ":" + pad(t.getMinutes()) } function break_text(c, text, x, y, width) { @@ -139,6 +142,8 @@ window.addEventListener("load", function() { } load_screenings(function() { + let ts = Date.now() + this.response.forEach(_add) console.log("Screenings in " + screenings_by_date.size + " days: ") @@ -186,5 +191,6 @@ window.addEventListener("load", function() { draw_screenings(c, s, start_time, rooms) } + console.log("Total elapsed time: " + (Date.now() - ts) + "ms.") }) }) -- cgit v1.2.3