1
0
Fork 0
mirror of https://git.sr.ht/~cadence/cloudtube synced 2026-05-26 12:32:25 +00:00

11x speed up of subscription page generation

My 30 subscriptions now take 25 ms to generate, instead of around 280.

Around 120 ms were saved by creating a database index.
Around 120 ms were saved by pre-compiling the pug template for video
description timestamps.
The other changes in this commit produced slight improvements.
This commit is contained in:
Cadence Ember 2021-08-26 23:47:53 +12:00
parent 0aa0505009
commit 55065e2a9e
No known key found for this signature in database
GPG key ID: BC1C2C61CF521B17
4 changed files with 15 additions and 9 deletions

View file

@ -58,6 +58,7 @@ function normaliseVideoInfo(video) {
}
}
const timeDisplayCompiled = pug.compile(`a(href=url data-clickable-timestamp=timeSeconds)= timeDisplay`)
function rewriteVideoDescription(descriptionHtml, id) {
// replace timestamps to clickable links and rewrite youtube links to stay on the instance instead of pointing to YouTube
// test cases
@ -93,7 +94,7 @@ function rewriteVideoDescription(descriptionHtml, id) {
params.set("t", timeURL)
const url = "/watch?" + params
return pug.render(`a(href=url data-clickable-timestamp=timeSeconds)= timeDisplay`, {url, timeURL, timeDisplay, timeSeconds})
return timeDisplayCompiled({url, timeURL, timeDisplay, timeSeconds})
})
return descriptionHtml