Giter Club home page Giter Club logo

Comments (8)

Zulko avatar Zulko commented on May 21, 2024 1

Since v0.1.4 ReLaXed is much faster, and also gives a better breakdown of it's different rendering steps, which should make it easier to optimize particular cases in the future. Turns out that mathjax rendering was also a bottleneck so it is now optional and replaceable by the faster Katex.

from relaxed.

DanielRuf avatar DanielRuf commented on May 21, 2024

Great idea.

Here are some of my thoughts and ideas:

page.eval with checking for documentReady or similar might be also a solution. Never checked for the idle status.

H(M)R is typically faster (that's what we do in React and other UI frameworks).

from relaxed.

Zulko avatar Zulko commented on May 21, 2024

The waitFor in the line linked is actually equivalent to a page.eval from what I understand.

from relaxed.

benperiton avatar benperiton commented on May 21, 2024

I'm not sure that Hot Reload would make a /massive/ difference, the time spent (for me at least) is printing the PDF, not generating the HTML.

Waiting until 'networkidle2' does seem to add an extra second to the PDF printing. Is this only needed if remote images/styles are being requested? If so could it be checked when creating the HTML with Cheerio and if there are any remote urls in the content, then set that option, otherwise ignore it?

Avg time ins seconds:

PDF Disabled PDF Enabled PDF Enabled - no networkidle2
Small (1 page) 0.10 1.19 0.30
Large (81 pages) 0.65 3.67 2.84

A quick test on a .pug file containing pug syntax/markdown and scss styling:

large.pug

  • 5390 lines
  • 81 pages

PDF Output disabled

[10:51:59] ben@helmclever ⮀ ~/D/W/R/test ⮀ relaxed src/large.pug doc/large.pdf --watch assets --temp tmp
Watching src/large.pug and its directory tree.

Processing detected change in /large.pug...
... done in 1.13s

Processing detected change in /large.pug...
... done in 0.76s

Processing detected change in /large.pug...
... done in 0.59s

Processing detected change in /large.pug...
... done in 0.60s

Processing detected change in /large.pug...
... done in 0.53s

Processing detected change in /large.pug...
... done in 0.58s

Processing detected change in /large.pug...
... done in 0.60s

Processing detected change in /large.pug...
... done in 0.58s

Processing detected change in /large.pug...
... done in 0.53s

Processing detected change in /large.pug...
... done in 0.55s

PDF Output enabled

[10:54:26] ben@helmclever ⮀ ~/D/W/R/test ⮀ relaxed src/large.pug doc/large.pdf --watch assets --temp tmp
Watching src/large.pug and its directory tree.

Processing detected change in /large.pug...
... done in 5.16s

Processing detected change in /large.pug...
... done in 3.47s

Processing detected change in /large.pug...
... done in 3.50s

Processing detected change in /large.pug...
... done in 3.51s

Processing detected change in /large.pug...
... done in 3.50s

Processing detected change in /large.pug...
... done in 3.43s

Processing detected change in /large.pug...
... done in 3.45s

Processing detected change in /large.pug...
... done in 3.49s

Processing detected change in /large.pug...
... done in 3.52s

Processing detected change in /large.pug...
... done in 3.68s

PDF Output enabled (without {waitUntil: 'networkidle2'})

[10:59:57] ben@helmclever ⮀ ~/D/W/R/test ⮀ relaxed src/large.pug doc/large.pdf --watch assets --temp tmp
Watching src/large.pug and its directory tree.

Processing detected change in /large.pug...
... done in 3.74s

Processing detected change in /large.pug...
... done in 2.88s

Processing detected change in /large.pug...
... done in 2.75s

Processing detected change in /large.pug...
... done in 2.74s

Processing detected change in /large.pug...
... done in 2.65s

Processing detected change in /large.pug...
... done in 2.73s

Processing detected change in /large.pug...
... done in 2.73s

Processing detected change in /large.pug...
... done in 2.76s

Processing detected change in /large.pug...
... done in 2.69s

Processing detected change in /large.pug...
... done in 2.70s

small.pug

  • 22 lines
  • 1 page

PDF Output disabled

[15:13:54] ben@helmclever ⮀ ~/D/W/R/test ⮀ relaxed src/small.pug doc/small.pdf --watch assets --temp tmp
Watching src/small.pug and its directory tree.

Processing detected change in /small.pug...
... done in 0.35s

Processing detected change in /small.pug...
... done in 0.10s

Processing detected change in /small.pug...
... done in 0.09s

Processing detected change in /small.pug...
... done in 0.13s

Processing detected change in /small.pug...
... done in 0.15s

Processing detected change in /small.pug...
... done in 0.09s

Processing detected change in /small.pug...
... done in 0.12s

Processing detected change in /small.pug...
... done in 0.12s

Processing detected change in /small.pug...
... done in 0.09s

Processing detected change in /small.pug...
... done in 0.12s

PDF Output enabled

[15:14:53] ben@helmclever ⮀ ~/D/W/R/test ⮀ relaxed src/small.pug doc/small.pdf --watch assets --temp tmp
Watching src/small.pug and its directory tree.

Processing detected change in /small.pug...
... done in 1.19s

Processing detected change in /small.pug...
... done in 1.18s

Processing detected change in /small.pug...
... done in 1.18s

Processing detected change in /small.pug...
... done in 1.19s

Processing detected change in /small.pug...
... done in 1.18s

Processing detected change in /small.pug...
... done in 1.22s

Processing detected change in /small.pug...
... done in 1.18s

Processing detected change in /small.pug...
... done in 1.20s

Processing detected change in /small.pug...
... done in 1.21s

Processing detected change in /small.pug...
... done in 1.21s

PDF Output enabled (without {waitUntil: 'networkidle2'})

[15:17:13] ben@helmclever ⮀ ~/D/W/R/test ⮀ relaxed src/small.pug doc/small.pdf --watch assets --temp tmp
Watching src/small.pug and its directory tree.

Processing detected change in /small.pug...
... done in 0.80s

Processing detected change in /small.pug...
... done in 0.24s

Processing detected change in /small.pug...
... done in 0.23s

Processing detected change in /small.pug...
... done in 0.26s

Processing detected change in /small.pug...
... done in 0.28s

Processing detected change in /small.pug...
... done in 0.26s

Processing detected change in /small.pug...
... done in 0.23s

Processing detected change in /small.pug...
... done in 0.25s

Processing detected change in /small.pug...
... done in 0.26s

Processing detected change in /small.pug...
... done in 0.21s

from relaxed.

Zulko avatar Zulko commented on May 21, 2024

@benperiton awesome, that's the kind of data I am after. The question is what happens for short files. In that case, I expect the processing time to be much less, and the networkidle2 overhead increases it severalfold.

from relaxed.

benperiton avatar benperiton commented on May 21, 2024

@Zulko I've added some numbers for a small.pug file. (and a little avg table)

from relaxed.

Zulko avatar Zulko commented on May 21, 2024

Awesome, so yeah, for small pug files, going from 1.20 to 0.20 seconds would be a great improvement, almost like real-time rendering. Very useful when you are crafting a leaflet or any otherwise complex one-page document.

from relaxed.

benperiton avatar benperiton commented on May 21, 2024

Yea, there's quite a big jump! It does seem that the first run is always slower than the rest, not quite sure why that is, it does skew the average slightly but potentially some low hanging fruit to speed it up overall.

from relaxed.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.