npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

template-bench

v0.1.0

Published

Benchmarks for several text/HTML templating engines

Downloads

4

Readme

template-bench

Last updated June 9, 2013.

This is meant to be a comprehensive benchmarking test for various templating engines.

The data provided to each benchmark cycles through various different inputs so as to cover each possible output within the template.

All tests have a similar output, but should go about them in different ways.

Provided data that looks like:

{
  title: "Everybody loves fruit",
  text: "List of fruits",
  items: [
    {
      url: "/items/apple",
      name: "Apple",
      price: 1.20,
      description: "I need my red delicious."
    },
    {
      url: "/items/banana",
      name: "Banana",
      price: 0.43,
      description: "Curved yellow fruit."
    }
  ]
}

Output something that looks like the following:

<!DOCTYPE html>
<html lang="en-us">
  <head>
    <title>Everybody loves fruit</title>
  </head>
  <body>
    <h1>List of fruits</h1>
    <dl id="items">
      <dt><a href="/items/apple">Apple</a>: $1.20</dt>
      <dd><p>I need my red delicious.</p></dd>
      <dt><a href="/items/banana">Banana</a>: $0.43</dt>
      <dd><p>Curved yellow fruit.</p></dd>
    </dl>
  </body>
</html>

If the projects array is empty, then it should look like the following:

<!DOCTYPE html>
<html lang="en-us">
  <head>
    <title>Everybody loves fruit</title>
  </head>
  <body>
    <h1>List of fruits</h1>
    <p id="no-items">There are no items at this time.</p>
  </body>
</html>

Unneeded whitespace may be omitted, but extra whitespace (such as before :) or lack of whitespace (such as after :) is a failure.

Templates are provided time to prepare if needed before running a series of tests on the prepared template with varying data.

All engines tested must be installable with npm and run on node's latest released version.

Engines are expected to use caching in order to not have to recompile each step. There is a prepare callback that can be run at the beginning which will not count against any score, and a full set of data will run through the template before scoring, which will have its output validated.

Installing

The easiest way is

# npm install -g template-bench

Command line

Once you have template-bench installed, you can run the binary

# template-bench --help

--help            Show this help screen                                                                                         [boolean]
-v, --version     template-bench v0.1.0                                                                                         [boolean]
-t, --time        Amount of time per benchmark in milliseconds                                                                  [default: 1000]
-d, --variations  Amount of variations in the data                                                                              [default: 25]
-e, --engine      A comma-separated list of the engines to test                                                               
-r, --test        A comma-separated list of tests to run (of escaped, unescaped, partial, singleInheritance, multiInheritance)

As the number of variations increases, the size of the input data grows as well, so for 50 variations, it will have data with 0 items all the way up to 50 items.

Engines can go over their allotted time in order to run a full set of variations, so that there is no bias.

Unescaped output

Allow all the input strings to be unescaped, so <script> stays <script>.

Escaped output

All input strings must be escaped, so <script> should turn into &lt;script&gt;.

Partials

Assuming the engine supports it, There should be a test where each <dt /><dd /> pair is in its own template which is included by the parent template. Text is unescaped.

Single-level inheritance

Assuming the engine supports it, there should be a test where in two separate templates, one inherits from the other. The contents of the <body> tag should be defined separately from the rest of the layout. Text is unescaped.

Multi-level inheritance

Assuming the engine supports it, there should be a test where one template inherits from another which itself inherits from another. The contents of the <body> tag should be the middle template and the contents of the <body> excluding the <h1> tag should be the lowest template. Text is unescaped.

Contributing

If you want to change an engine or add a new one, submit a pull request. If you want to suggest a new benchmark or have any other suggestions, submit an issue.