diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2019-10-05 14:05:11 +0200 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2019-10-05 14:05:11 +0200 |
commit | e78b32968fe6fdc2494b3d42fbd72848b3fc8b5c (patch) | |
tree | 05cb588cb82924f80dcb2d70931727f7e93cb934 | |
parent | aa41ebfc002f98a0dcab5f5d8ea90cc8ce74406e (diff) | |
download | ramaskrik-social-e78b32968fe6fdc2494b3d42fbd72848b3fc8b5c.tar.gz ramaskrik-social-e78b32968fe6fdc2494b3d42fbd72848b3fc8b5c.tar.bz2 ramaskrik-social-e78b32968fe6fdc2494b3d42fbd72848b3fc8b5c.zip |
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.
-rw-r--r-- | public/js/app.js | 12 |
1 files changed, 9 insertions, 3 deletions
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.") }) }) |