From 3ec30e28aac3b3b7e6512060d6368e9bceeafec9 Mon Sep 17 00:00:00 2001 From: Jared White Date: Sun, 8 Sep 2024 08:38:44 -0700 Subject: [PATCH] Upgrade Streamlined dependency to 0.6.0 --- Gemfile.lock | 4 +- .../benchmark/erb-vs-streamlined.rb | 67 +++++++++++++++++++ bridgetown-core/bridgetown-core.gemspec | 2 +- 3 files changed, 70 insertions(+), 3 deletions(-) create mode 100755 bridgetown-core/benchmark/erb-vs-streamlined.rb diff --git a/Gemfile.lock b/Gemfile.lock index 201bf7663..e0c89e21d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -29,7 +29,7 @@ PATH rouge (>= 3.0, < 5.0) serbea (~> 2.1) signalize (~> 1.3) - streamlined (>= 0.5.2) + streamlined (>= 0.6.0) thor (~> 1.1) tilt (~> 2.0) zeitwerk (~> 2.5) @@ -224,7 +224,7 @@ GEM thor (~> 1.0) tilt (~> 2.0) yard (~> 0.9, >= 0.9.24) - streamlined (0.5.2) + streamlined (0.6.0) serbea (>= 2.1) zeitwerk (~> 2.5) terminal-table (3.0.2) diff --git a/bridgetown-core/benchmark/erb-vs-streamlined.rb b/bridgetown-core/benchmark/erb-vs-streamlined.rb new file mode 100755 index 000000000..845426d07 --- /dev/null +++ b/bridgetown-core/benchmark/erb-vs-streamlined.rb @@ -0,0 +1,67 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require "bundler" +Bundler.setup +require "benchmark/ips" +require "bridgetown" + +include ::Streamlined::Renderable + +def erb_out + @erbtmpl ||= Tilt::ErubiTemplate.new( + outvar: "@_erbout", + bufval: "Bridgetown::OutputBuffer.new", + engine_class: Bridgetown::ERBEngine + ) { erb_content } + @erbtmpl.render(self) +end + +def erb_content + <<~ERB +

<%= 123 + 99 %>

+ <%= erb2_out %> + ERB +end + +def erb2_out + @erb2tmpl ||= Tilt::ErubiTemplate.new( + outvar: "@_erbout", + bufval: "Bridgetown::OutputBuffer.new", + engine_class: Bridgetown::ERBEngine + ) { erb2_content } + @erb2tmpl.render(self) +end + +def erb2_content + <<~ERB +

<%= version %>

+ ERB +end + +def streamlined_out + html -> { <<~HTML +

#{text -> { 123 + 99 }}

+ #{html -> { streamlined2_out }} + HTML + } +end + +def streamlined2_out + <<~HTML +

#{text -> { version }}

+ HTML +end + +def version + "#{Bridgetown::VERSION}" +end + +puts erb_out +puts "---" +puts streamlined_out.to_s + +Benchmark.ips do |x| + x.report("erb") { erb_out } + x.report("streamlined") { streamlined_out.to_s } +end diff --git a/bridgetown-core/bridgetown-core.gemspec b/bridgetown-core/bridgetown-core.gemspec index 378764cee..0a3bc1f8b 100644 --- a/bridgetown-core/bridgetown-core.gemspec +++ b/bridgetown-core/bridgetown-core.gemspec @@ -52,7 +52,7 @@ Gem::Specification.new do |s| s.add_runtime_dependency("rouge", [">= 3.0", "< 5.0"]) s.add_runtime_dependency("serbea", "~> 2.1") s.add_runtime_dependency("signalize", "~> 1.3") - s.add_runtime_dependency("streamlined", ">= 0.5.2") + s.add_runtime_dependency("streamlined", ">= 0.6.0") s.add_runtime_dependency("thor", "~> 1.1") s.add_runtime_dependency("tilt", "~> 2.0") s.add_runtime_dependency("zeitwerk", "~> 2.5")