-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
98 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require "benchmark" | ||
|
||
require "./blueprint_html" | ||
require "./blueprint_raw_html" | ||
require "./ecr" | ||
|
||
require "../src/blueprint/version" | ||
|
||
blueprint_html = BlueprintHTML::Page.new.to_html | ||
blueprint_raw_html = BlueprintRawHTML::Page.new.to_html | ||
ecr = ECR::Page.new.to_s # ECR is here just to have a base value to compare | ||
|
||
raise "Different results" if blueprint_html != blueprint_raw_html && blueprint_html != ecr | ||
|
||
Benchmark.ips do |x| | ||
x.report("Blueprint::HTML #{Blueprint::VERSION}") { BlueprintHTML::Page.new.to_html } | ||
x.report("Blueprint::RawHTML #{Blueprint::VERSION}") { BlueprintRawHTML::Page.new.to_html } | ||
x.report("ECR") { ECR::Page.new.to_s } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
require "../src/blueprint/raw_html" | ||
|
||
class BlueprintRawHTML::LayoutComponent | ||
include Blueprint::RawHTML | ||
|
||
def initialize(@title = "Example"); end | ||
|
||
def blueprint(&) | ||
html do | ||
head do | ||
title @title | ||
meta name: "viewport", content: "width=device-width,initial-scale=1" | ||
link href: "/assets/tailwind.css", rel: "stylesheet" | ||
end | ||
|
||
body class: "bg-zinc-100" do | ||
nav class: "p-5", id: "main_nav" do | ||
ul do | ||
li(class: "p-5") { a("Home", href: "/") } | ||
li(class: "p-5") { a("About", href: "/about") } | ||
li(class: "p-5") { a("Contact", href: "/contact") } | ||
end | ||
end | ||
|
||
div class: "container mx-auto p-5" do | ||
yield | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
class BlueprintRawHTML::Page | ||
include Blueprint::RawHTML | ||
|
||
def blueprint | ||
render BlueprintRawHTML::LayoutComponent.new do | ||
h1 "Hi" | ||
|
||
table id: "test", class: "a b c d e f g" do | ||
tr do | ||
td id: "test", class: "a b c d e f g" do | ||
span "Hi" | ||
end | ||
|
||
td id: "test", class: "a b c d e f g" do | ||
span "Hi" | ||
end | ||
|
||
td id: "test", class: "a b c d e f g" do | ||
span "Hi" | ||
end | ||
|
||
td id: "test", class: "a b c d e f g" do | ||
span "Hi" | ||
end | ||
|
||
td id: "test", class: "a b c d e f g" do | ||
span "Hi" | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
require "ecr" | ||
|
||
module ECR | ||
class Page | ||
def initialize(@title = "Example") | ||
end | ||
|
||
ECR.def_to_s("./benchmark/ecr_template.ecr") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<html><head><title><%= @title %></title><meta name="viewport" content="width=device-width,initial-scale=1"><link href="/assets/tailwind.css" rel="stylesheet"></head><body class="bg-zinc-100"><nav class="p-5" id="main_nav"><ul><li class="p-5"><a href="/">Home</a></li><li class="p-5"><a href="/about">About</a></li><li class="p-5"><a href="/contact">Contact</a></li></ul></nav><div class="container mx-auto p-5"><h1>Hi</h1><table id="test" class="a b c d e f g"><tr><td id="test" class="a b c d e f g"><span>Hi</span></td><td id="test" class="a b c d e f g"><span>Hi</span></td><td id="test" class="a b c d e f g"><span>Hi</span></td><td id="test" class="a b c d e f g"><span>Hi</span></td><td id="test" class="a b c d e f g"><span>Hi</span></td></tr></table></div></body></html> |