<commit_before>const { time } = require('brisky-performance');
const beard = require('./beard');

const benchmarkTemplate = function(name, path, engine, times = 10000) {
  let start;
  let elapsed;

  console.log(name);
  console.log('--');

  engine.render(path);

  start = time();
  for(i = 0; i < times; i++) engine.render(path);
  elapsed = time(start);
  console.log(`Rendering ${times} times with caching took ${elapsed}ms to complete.`);

  console.log('\n');
}

benchmarkTemplate('Simple Content', 'content', beard({'content': 'some content'}));

benchmarkTemplate(
  'Page with Layout',
  'page',
  beard({
    'page': "{{extends 'layout'}}page content{{block header}}the header{{endblock}}",
    'layout': 'top of page {{header}} -- {{view}} -- the footer'
  })
);

benchmarkTemplate(
  'Page with Layout with Path Lookup',
  'page',
  beard({
    '/views/page': "{{extends 'layout'}}page content{{block header}}the header{{endblock}}",
    '/views/layout': 'top of page {{header}} -- {{view}} -- the footer'
  },
    (path, parentPath) => `/views/${path}`
  )
);<commit_msg>Fix benchmarks for updated template caching<commit_after>const { time } = require('brisky-performance');
const beard = require('./beard');

const benchmarkTemplate = function(name, path, engine, times = 10000) {
  let start;
  let elapsed;

  console.log(name);
  console.log('--');

  engine.render(path);

  start = time();
  for(i = 0; i < times; i++) engine.render(path);
  elapsed = time(start);
  console.log(`Rendering ${times} times with caching took ${elapsed}ms to complete.`);

  console.log('\n');
}

benchmarkTemplate('Simple Content', 'content', beard({'/content': 'some content'}));

benchmarkTemplate(
  'Page with Layout',
  'page',
  beard({
    '/page': "{{extends 'layout'}}page content{{block header}}the header{{endblock}}",
    '/layout': 'top of page {{header}} -- {{view}} -- the footer'
  })
);
{'fraction_non_alphanumeric': 0.1993704092339979, 'fraction_numerical': 0.0062959076600209865, 'mean_word_length': 4.356741573033708, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3338103', 'n_tokens_mistral': 631, 'n_tokens_neox': 609, 'n_words': 163}