Skip to content

Commit 2387b03

Browse files
committed
Merge pull request #62 from lpil/feature/benchmarks
Add a largely meaningless benchmark
2 parents 96663fb + dc3b19f commit 2387b03

File tree

4 files changed

+52
-2
lines changed

4 files changed

+52
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
/deps
33
erl_crash.dump
44
*.ez
5+
/bench/snapshots

bench/eex_comparison_bench.exs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
defmodule EExComparisonBench do
2+
use Benchfella
3+
require SlimFast
4+
5+
SlimFast.function_from_string :def, :slim_fast, """
6+
- site_title = "Hello, world!"
7+
doctype html
8+
html
9+
head
10+
meta name="keywords" description="slim fast"
11+
title = site_title
12+
body
13+
#id.class
14+
ul
15+
= for x <- [1, 2] do
16+
li = x
17+
"""
18+
19+
EEx.function_from_string :def, :eex, """
20+
<% site_title = "Hello, world!" %>
21+
<!DOCTYPE html>
22+
<html>
23+
<head>
24+
<meta name="keywords">
25+
<title><%= site_title %></title>
26+
</head>
27+
28+
<body>
29+
<div class="class" id="id">
30+
<ul>
31+
<%= for x <- [1, 2] do %>
32+
<li><%= x %></li>
33+
<% end %>
34+
</ul>
35+
</div>
36+
</body>
37+
</html>
38+
"""
39+
40+
bench "SlimFast" do
41+
slim_fast()
42+
end
43+
44+
bench "EEx" do
45+
eex()
46+
end
47+
end

mix.exs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ defmodule SlimFast.Mixfile do
2626

2727
def deps do
2828
[
29-
{:phoenix_html, "~> 2.2", only: :test}
29+
{:phoenix_html, "~> 2.2", only: :test},
30+
{:benchfella, "~> 0.3", only: ~w(dev test)a},
3031
]
3132
end
3233
end

mix.lock

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
%{"phoenix_html": {:hex, :phoenix_html, "2.2.0"},
1+
%{"benchfella": {:hex, :benchfella, "0.3.1"},
2+
"phoenix_html": {:hex, :phoenix_html, "2.2.0"},
23
"plug": {:hex, :plug, "1.0.2"}}

0 commit comments

Comments
 (0)