3 raco beeswax render
This command renders a Pollen source (or any file that provides Pollen’s standard identifiers doc and metas) using the appropriate Beeswax template.
Use raco beeswax render in preference to raco pollen render when you want speed over convenience. This command is stupid but fast.
> raco beeswax render source ... |
As with Pollen:
The optional -t or --target switch specifies the target file type to use for multi-output source files and ambiguously-named files. (Files that specify a specific output target will still be rendered as usual.) Like Pollen, this defaults to whatever appears first in (setup:poly-targets).
This command makes use of Pollen’s compile cache; if the source file has not been compiled, it will be compiled and cached; if it has already been compiled, the cached copy is used.
Unlike Pollen:
You can only specify source files —
not directories and not output files. If you want to render a bunch of files, list them out separately or use wildcards. In any case, each output filename is derived from the source filename, incorporating the --target value to get the extension when necessary. You cannot specify Preprocessor (.pp extension) files or Scribble files with this command.
There is not (yet) a parallel rendering option. All the files are rendered in sequence using a single core. On my personal (not very new) laptop, this method can still produce 75 HTML files in 3–4 seconds. This is fast enough that I haven’t bothered with the additional complexity of offering full use of all available cores.
This command does not use Pollen’s (or any) render caching; it will always write the output file to disk, even if none of its dependencies have changed. If the output file exists, it will always be silently overwritten.
3.1 Optimizing renders
3.1.1 Use raco make on your templates
You will get a noticeable speed increase by precompiling your Beeswax template with raco make:
> raco make template.html.rkt |
This will speed things up no matter what method you use to apply your Beeswax templates —
Perhaps Beeswax will do this for you at some point, but for now, it doesn’t. You can either do it manually, or automate it along with the rest of your build by using a makefile.
3.1.2 Example benchmarks
Here we compare three render times for the same source document: one using Pollen (with a Pollen template), one using raco beeswax render, and another using raco beeswax render with a precompiled template. The source document and Pollen and Beeswax templates used are the same ones shown in the tutorial.
The commands shown are actually run each time this documentation is built, so the time measurements reflect the performance of whatever environment was used to built this copy of this document.
If you are viewing this document from a local Racket installation, these are your computer’s numbers! They depend not only on the hardware, but also the nature of other workloads running at the same time in that environment. The times reflected on docs.racket-lang.org are generally going to be slower than those measured on your local computer.
# Reset the compile cache |
> raco pollen reset |
pollen: resetting cache ... |
|
# "Preheat the cache" |
> raco pollen setup |
pollen: preheating cache ... |
pollen: caching: fleas.html.pm |
|
# Pollen render (without the Beeswax external-renderer) |
> raco pollen render fleas.html |
pollen: rendering fleas.html |
pollen: rendering /fleas.html.pm |
pollen: rendered /fleas.html (106 ms) |
|
# Beeswax render |
> raco beeswax render fleas.html.pm |
beeswax: rendered /fleas.html.pm → /fleas.html (117ms) |
|
# Make Beeswax go even faster by precompiling the template |
> raco make template.html.rkt |
|
> raco beeswax render fleas.html.pm |
beeswax: rendered /fleas.html.pm → /fleas.html (16ms) |