hamlit 2.15.0 → 2.15.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/bench.yml +46 -0
- data/CHANGELOG.md +7 -0
- data/hamlit.gemspec +1 -1
- data/lib/hamlit/version.rb +1 -1
- metadata +4 -37
- data/benchmark/boolean_attribute.haml +0 -6
- data/benchmark/class_attribute.haml +0 -5
- data/benchmark/common_attribute.haml +0 -3
- data/benchmark/data_attribute.haml +0 -4
- data/benchmark/dynamic_attributes/boolean_attribute.haml +0 -4
- data/benchmark/dynamic_attributes/class_attribute.haml +0 -4
- data/benchmark/dynamic_attributes/common_attribute.haml +0 -2
- data/benchmark/dynamic_attributes/data_attribute.haml +0 -2
- data/benchmark/dynamic_attributes/id_attribute.haml +0 -2
- data/benchmark/dynamic_boolean_attribute.haml +0 -4
- data/benchmark/dynamic_merger/benchmark.rb +0 -25
- data/benchmark/dynamic_merger/hello.haml +0 -50
- data/benchmark/dynamic_merger/hello.string +0 -50
- data/benchmark/etc/attribute_builder.haml +0 -5
- data/benchmark/etc/real_sample.haml +0 -888
- data/benchmark/etc/real_sample.rb +0 -11
- data/benchmark/etc/static_analyzer.haml +0 -1
- data/benchmark/etc/string_interpolation.haml +0 -2
- data/benchmark/etc/tags.haml +0 -3
- data/benchmark/etc/tags_loop.haml +0 -2
- data/benchmark/ext/build_data.rb +0 -17
- data/benchmark/ext/build_id.rb +0 -13
- data/benchmark/graph/graph.key +0 -0
- data/benchmark/graph/graph.png +0 -0
- data/benchmark/id_attribute.haml +0 -3
- data/benchmark/plain.haml +0 -4
- data/benchmark/script.haml +0 -4
- data/benchmark/slim/LICENSE +0 -21
- data/benchmark/slim/context.rb +0 -11
- data/benchmark/slim/run-benchmarks.rb +0 -94
- data/benchmark/slim/view.erb +0 -23
- data/benchmark/slim/view.haml +0 -18
- data/benchmark/slim/view.slim +0 -17
- data/benchmark/utils/benchmark_ips_extension.rb +0 -43
@@ -1 +0,0 @@
|
|
1
|
-
#foo.bar{ data: { 'user' => { id: 1234, name: 'k0kubun' }, book_id: 5432 } }
|
data/benchmark/etc/tags.haml
DELETED
data/benchmark/ext/build_data.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'bundler/setup'
|
4
|
-
require 'hamlit'
|
5
|
-
require 'faml'
|
6
|
-
require 'benchmark/ips'
|
7
|
-
require_relative '../utils/benchmark_ips_extension'
|
8
|
-
|
9
|
-
h = { 'user' => { id: 1234, name: 'k0kubun' }, book_id: 5432 }
|
10
|
-
|
11
|
-
Benchmark.ips do |x|
|
12
|
-
quote = "'"
|
13
|
-
faml_options = { data: h }
|
14
|
-
x.report("Faml::AB.build") { Faml::AttributeBuilder.build(quote, true, nil, faml_options) }
|
15
|
-
x.report("Hamlit.build_data") { Hamlit::AttributeBuilder.build_data(true, quote, h) }
|
16
|
-
x.compare!
|
17
|
-
end
|
data/benchmark/ext/build_id.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'bundler/setup'
|
4
|
-
require 'hamlit'
|
5
|
-
require 'faml'
|
6
|
-
require 'benchmark/ips'
|
7
|
-
require_relative '../utils/benchmark_ips_extension'
|
8
|
-
|
9
|
-
Benchmark.ips do |x|
|
10
|
-
x.report("Faml::AB.build") { Faml::AttributeBuilder.build("'", true, nil, {:id=>"book"}, id: %w[content active]) }
|
11
|
-
x.report("Hamlit::AB.build_id") { Hamlit::AttributeBuilder.build_id(true, "book", %w[content active]) }
|
12
|
-
x.compare!
|
13
|
-
end
|
data/benchmark/graph/graph.key
DELETED
Binary file
|
data/benchmark/graph/graph.png
DELETED
Binary file
|
data/benchmark/id_attribute.haml
DELETED
data/benchmark/plain.haml
DELETED
data/benchmark/script.haml
DELETED
data/benchmark/slim/LICENSE
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
The MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2010 - 2015 Slim Team
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
THE SOFTWARE.
|
data/benchmark/slim/context.rb
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
=begin
|
4
|
-
The MIT License
|
5
|
-
|
6
|
-
Copyright (c) 2010 - 2015 Slim Team
|
7
|
-
|
8
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
9
|
-
of this software and associated documentation files (the "Software"), to deal
|
10
|
-
in the Software without restriction, including without limitation the rights
|
11
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
12
|
-
copies of the Software, and to permit persons to whom the Software is
|
13
|
-
furnished to do so, subject to the following conditions:
|
14
|
-
|
15
|
-
The above copyright notice and this permission notice shall be included in
|
16
|
-
all copies or substantial portions of the Software.
|
17
|
-
|
18
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
21
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
24
|
-
THE SOFTWARE.
|
25
|
-
=end
|
26
|
-
|
27
|
-
#
|
28
|
-
# Original: https://github.com/slim-template/slim/blob/v3.0.6/benchmarks/run-benchmarks.rb
|
29
|
-
#
|
30
|
-
# SlimBenchmarks with following modifications:
|
31
|
-
# 1. Skipping slow engines, tilt and parsing benches.
|
32
|
-
# 2. All Ruby script and attributes are escaped for fairness.
|
33
|
-
# 3. Faml and Hamlit are added.
|
34
|
-
#
|
35
|
-
|
36
|
-
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'), File.dirname(__FILE__))
|
37
|
-
|
38
|
-
require 'slim'
|
39
|
-
require 'context'
|
40
|
-
|
41
|
-
require 'benchmark/ips'
|
42
|
-
require 'tilt'
|
43
|
-
require 'erubi'
|
44
|
-
require 'erb'
|
45
|
-
require 'haml'
|
46
|
-
require 'faml'
|
47
|
-
require 'hamlit'
|
48
|
-
|
49
|
-
class SlimBenchmarks
|
50
|
-
def initialize(only_haml)
|
51
|
-
@only_haml = only_haml
|
52
|
-
@benches = []
|
53
|
-
|
54
|
-
@erb_code = File.read(File.dirname(__FILE__) + '/view.erb')
|
55
|
-
@haml_code = File.read(File.dirname(__FILE__) + '/view.haml')
|
56
|
-
@slim_code = File.read(File.dirname(__FILE__) + '/view.slim')
|
57
|
-
|
58
|
-
init_compiled_benches
|
59
|
-
end
|
60
|
-
|
61
|
-
def init_compiled_benches
|
62
|
-
context = Context.new
|
63
|
-
|
64
|
-
haml_ugly = Haml::Engine.new(@haml_code, format: :html5, escape_html: true)
|
65
|
-
haml_ugly.def_method(context, :run_haml_ugly)
|
66
|
-
context.instance_eval %{
|
67
|
-
def run_erubi; #{Erubi::Engine.new(@erb_code).src}; end
|
68
|
-
def run_slim_ugly; #{Slim::Engine.new.call @slim_code}; end
|
69
|
-
def run_faml; #{Faml::Engine.new.call @haml_code}; end
|
70
|
-
def run_hamlit; #{Hamlit::Engine.new.call @haml_code}; end
|
71
|
-
}
|
72
|
-
|
73
|
-
bench("erubi v#{Erubi::VERSION}") { context.run_erubi } unless @only_haml
|
74
|
-
bench("slim v#{Slim::VERSION}") { context.run_slim_ugly } unless @only_haml
|
75
|
-
bench("haml v#{Haml::VERSION}") { context.run_haml_ugly }
|
76
|
-
bench("faml v#{Faml::VERSION}") { context.run_faml }
|
77
|
-
bench("hamlit v#{Hamlit::VERSION}") { context.run_hamlit }
|
78
|
-
end
|
79
|
-
|
80
|
-
def run
|
81
|
-
Benchmark.ips do |x|
|
82
|
-
@benches.each do |name, block|
|
83
|
-
x.report(name.to_s, &block)
|
84
|
-
end
|
85
|
-
x.compare!
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def bench(name, &block)
|
90
|
-
@benches.push([name, block])
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
SlimBenchmarks.new(ENV['ONLY_HAML'] == '1').run
|
data/benchmark/slim/view.erb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
<!DOCTYPE HTML>
|
2
|
-
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<title>Simple Benchmark</title>
|
6
|
-
</head>
|
7
|
-
<body>
|
8
|
-
<h1><%== header %></h1>
|
9
|
-
<% unless item.empty? %>
|
10
|
-
<ul>
|
11
|
-
<% for i in item %>
|
12
|
-
<% if i[:current] %>
|
13
|
-
<li><strong><%== i[:name] %></strong></li>
|
14
|
-
<% else %>
|
15
|
-
<li><a href="<%== i[:url] %>"><%== i[:name] %></a></li>
|
16
|
-
<% end %>
|
17
|
-
<% end %>
|
18
|
-
</ul>
|
19
|
-
<% else %>
|
20
|
-
<p>The list is empty.</p>
|
21
|
-
<% end %>
|
22
|
-
</body>
|
23
|
-
</html>
|
data/benchmark/slim/view.haml
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
!!! html
|
2
|
-
|
3
|
-
%html
|
4
|
-
%head
|
5
|
-
%title Simple Benchmark
|
6
|
-
%body
|
7
|
-
%h1= header
|
8
|
-
- unless item.empty?
|
9
|
-
%ul
|
10
|
-
- for i in item
|
11
|
-
- if i[:current]
|
12
|
-
%li
|
13
|
-
%strong= i[:name]
|
14
|
-
- else
|
15
|
-
%li
|
16
|
-
%a{:href => i[:url]}= i[:name]
|
17
|
-
- else
|
18
|
-
%p The list is empty.
|
data/benchmark/slim/view.slim
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
# Monkey patch to show milliseconds
|
2
|
-
module Benchmark
|
3
|
-
module IPS
|
4
|
-
class Report
|
5
|
-
module EntryExtension
|
6
|
-
def body
|
7
|
-
return super if Benchmark::IPS.options[:format] != :human
|
8
|
-
|
9
|
-
left = "%s i/s (%1.3fms)" % [Helpers.scale(ips), (1000.0 / ips)]
|
10
|
-
iters = Helpers.scale(@iterations)
|
11
|
-
|
12
|
-
if @show_total_time
|
13
|
-
left.ljust(20) + (" - %s in %10.6fs" % [iters, runtime])
|
14
|
-
else
|
15
|
-
left.ljust(20) + (" - %s" % iters)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
Entry.prepend(EntryExtension)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
module CompareExtension
|
24
|
-
def compare(*reports)
|
25
|
-
return if reports.size < 2
|
26
|
-
|
27
|
-
sorted = reports.sort_by(&:ips).reverse
|
28
|
-
best = sorted.shift
|
29
|
-
$stdout.puts "\nComparison:"
|
30
|
-
$stdout.printf "%20s: %10.1f i/s (%1.3fms)\n", best.label, best.ips, (1000.0 / best.ips)
|
31
|
-
|
32
|
-
sorted.each do |report|
|
33
|
-
name = report.label.to_s
|
34
|
-
|
35
|
-
x = (best.ips.to_f / report.ips.to_f)
|
36
|
-
$stdout.printf "%20s: %10.1f i/s (%1.3fms) - %.2fx slower\n", name, report.ips, (1000.0 / report.ips), x
|
37
|
-
end
|
38
|
-
|
39
|
-
$stdout.puts
|
40
|
-
end
|
41
|
-
end
|
42
|
-
extend CompareExtension
|
43
|
-
end
|