From 08fe54e03da025cda24c4b25b5b8a8d0007b4689 Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Sun, 16 Jan 2022 14:45:19 -0600 Subject: [PATCH] Minor tweaks to help with the https://github.com/11ty/eleventy-plugin-directory-output plugin --- src/BenchmarkGroup.js | 4 ++++ src/BenchmarkManager.js | 4 ++++ src/TemplateContent.js | 16 +++++++++++++--- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/BenchmarkGroup.js b/src/BenchmarkGroup.js index deb7f64dd..1f51addf6 100644 --- a/src/BenchmarkGroup.js +++ b/src/BenchmarkGroup.js @@ -66,6 +66,10 @@ class BenchmarkGroup { this.minimumThresholdPercent = val; } + has(type) { + return !!this.benchmarks[type]; + } + get(type) { if (!this.benchmarks[type]) { this.benchmarks[type] = new Benchmark(); diff --git a/src/BenchmarkManager.js b/src/BenchmarkManager.js index 1caddd688..c656e3c5f 100644 --- a/src/BenchmarkManager.js +++ b/src/BenchmarkManager.js @@ -29,6 +29,10 @@ class BenchmarkManager { this.isVerbose = !!isVerbose; } + hasBenchmarkGroup(name) { + return name in this.benchmarkGroups; + } + getBenchmarkGroup(name) { if (!this.benchmarkGroups[name]) { this.benchmarkGroups[name] = new BenchmarkGroup(); diff --git a/src/TemplateContent.js b/src/TemplateContent.js index 1f82ecf36..ec210e2f2 100644 --- a/src/TemplateContent.js +++ b/src/TemplateContent.js @@ -290,9 +290,7 @@ class TemplateContent { } let templateBenchmark = this.bench.get("Template Compile"); - let inputPathBenchmark = this.bench.get( - `> Template Compile > ${this.inputPath}` - ); + let inputPathBenchmark = this.bench.get(`> Compile > ${this.inputPath}`); templateBenchmark.before(); inputPathBenchmark.before(); let fn = await this.templateRender.getCompiledTemplate(str); @@ -416,14 +414,26 @@ class TemplateContent { let inputPathBenchmark = this.bench.get( `> Render > ${this.inputPath}${paginationSuffix.join("")}` ); + let outputPathBenchmark; + if (data.page && data.page.outputPath) { + outputPathBenchmark = this.bench.get( + `> Render > ${data.page.outputPath}` + ); + } templateBenchmark.before(); if (inputPathBenchmark) { inputPathBenchmark.before(); } + if (outputPathBenchmark) { + outputPathBenchmark.before(); + } let rendered = await fn(data); + if (outputPathBenchmark) { + outputPathBenchmark.after(); + } if (inputPathBenchmark) { inputPathBenchmark.after(); }