cataract 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci-manual-rubies.yml +44 -0
- data/.overcommit.yml +1 -1
- data/.rubocop.yml +96 -4
- data/.rubocop_todo.yml +186 -0
- data/BENCHMARKS.md +62 -141
- data/CHANGELOG.md +20 -0
- data/RAGEL_MIGRATION.md +2 -2
- data/README.md +37 -4
- data/Rakefile +72 -32
- data/cataract.gemspec +4 -1
- data/ext/cataract/cataract.c +59 -50
- data/ext/cataract/cataract.h +5 -3
- data/ext/cataract/css_parser.c +173 -65
- data/ext/cataract/extconf.rb +2 -2
- data/ext/cataract/{merge.c → flatten.c} +526 -468
- data/ext/cataract/shorthand_expander.c +164 -115
- data/lib/cataract/at_rule.rb +8 -9
- data/lib/cataract/declaration.rb +18 -0
- data/lib/cataract/import_resolver.rb +63 -43
- data/lib/cataract/import_statement.rb +49 -0
- data/lib/cataract/pure/byte_constants.rb +69 -0
- data/lib/cataract/pure/flatten.rb +1145 -0
- data/lib/cataract/pure/helpers.rb +35 -0
- data/lib/cataract/pure/imports.rb +268 -0
- data/lib/cataract/pure/parser.rb +1340 -0
- data/lib/cataract/pure/serializer.rb +590 -0
- data/lib/cataract/pure/specificity.rb +206 -0
- data/lib/cataract/pure.rb +153 -0
- data/lib/cataract/rule.rb +69 -15
- data/lib/cataract/stylesheet.rb +356 -49
- data/lib/cataract/version.rb +1 -1
- data/lib/cataract.rb +43 -26
- metadata +14 -26
- data/benchmarks/benchmark_harness.rb +0 -193
- data/benchmarks/benchmark_merging.rb +0 -121
- data/benchmarks/benchmark_optimization_comparison.rb +0 -168
- data/benchmarks/benchmark_parsing.rb +0 -153
- data/benchmarks/benchmark_ragel_removal.rb +0 -56
- data/benchmarks/benchmark_runner.rb +0 -70
- data/benchmarks/benchmark_serialization.rb +0 -180
- data/benchmarks/benchmark_shorthand.rb +0 -109
- data/benchmarks/benchmark_shorthand_expansion.rb +0 -176
- data/benchmarks/benchmark_specificity.rb +0 -124
- data/benchmarks/benchmark_string_allocation.rb +0 -151
- data/benchmarks/benchmark_stylesheet_to_s.rb +0 -62
- data/benchmarks/benchmark_to_s_cached.rb +0 -55
- data/benchmarks/benchmark_value_splitter.rb +0 -54
- data/benchmarks/benchmark_yjit.rb +0 -158
- data/benchmarks/benchmark_yjit_workers.rb +0 -61
- data/benchmarks/profile_to_s.rb +0 -23
- data/benchmarks/speedup_calculator.rb +0 -83
- data/benchmarks/system_metadata.rb +0 -81
- data/benchmarks/templates/benchmarks.md.erb +0 -221
- data/benchmarks/yjit_tests.rb +0 -141
- data/scripts/fuzzer/run.rb +0 -828
- data/scripts/fuzzer/worker.rb +0 -99
- data/scripts/generate_benchmarks_md.rb +0 -155
data/benchmarks/yjit_tests.rb
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Shared test logic for YJIT benchmarks
|
|
4
|
-
# Extended by both YjitWithoutBenchmark and YjitWithBenchmark
|
|
5
|
-
module YjitTests
|
|
6
|
-
SAMPLE_CSS = <<~CSS
|
|
7
|
-
body { margin: 0; padding: 0; font-family: Arial, sans-serif; }
|
|
8
|
-
.header { color: #333; padding: 20px; background: #f8f9fa; }
|
|
9
|
-
.container { max-width: 1200px; margin: 0 auto; }
|
|
10
|
-
div p { line-height: 1.6; }
|
|
11
|
-
.container > .item { margin-bottom: 20px; }
|
|
12
|
-
h1 + p { margin-top: 0; font-size: 1.2em; }
|
|
13
|
-
CSS
|
|
14
|
-
|
|
15
|
-
def self.metadata
|
|
16
|
-
{
|
|
17
|
-
'operations' => [
|
|
18
|
-
'property access',
|
|
19
|
-
'declaration merging',
|
|
20
|
-
'to_s generation',
|
|
21
|
-
'parse + iterate'
|
|
22
|
-
],
|
|
23
|
-
'note' => 'C extension performance is the same regardless of YJIT. This measures Ruby code.'
|
|
24
|
-
}
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def self.speedup_config
|
|
28
|
-
# Compare without YJIT (baseline) vs with YJIT (comparison)
|
|
29
|
-
{
|
|
30
|
-
baseline_matcher: SpeedupCalculator::Matchers.without_yjit,
|
|
31
|
-
comparison_matcher: SpeedupCalculator::Matchers.with_yjit,
|
|
32
|
-
test_case_key: nil # No test_cases array, just operations
|
|
33
|
-
}
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def sanity_checks
|
|
37
|
-
# Verify basic operations work
|
|
38
|
-
decls = Cataract::Declarations.new
|
|
39
|
-
decls['color'] = 'red'
|
|
40
|
-
raise 'Property access failed' unless decls['color']
|
|
41
|
-
|
|
42
|
-
parser = Cataract::Stylesheet.new
|
|
43
|
-
parser.add_block(SAMPLE_CSS)
|
|
44
|
-
raise 'Parse failed' if parser.rules_count.zero?
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def call
|
|
48
|
-
run_property_access_benchmark
|
|
49
|
-
run_declaration_merging_benchmark
|
|
50
|
-
run_to_s_benchmark
|
|
51
|
-
run_parse_iterate_benchmark
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
private
|
|
55
|
-
|
|
56
|
-
def yjit_label
|
|
57
|
-
@yjit_label ||= defined?(RubyVM::YJIT.enabled?) && RubyVM::YJIT.enabled? ? 'YJIT' : 'no YJIT'
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def run_property_access_benchmark
|
|
61
|
-
puts '=' * 80
|
|
62
|
-
puts "TEST: Property access (get/set) - #{yjit_label}"
|
|
63
|
-
puts '=' * 80
|
|
64
|
-
|
|
65
|
-
benchmark('property_access') do |x|
|
|
66
|
-
x.config(time: 3, warmup: 1)
|
|
67
|
-
|
|
68
|
-
x.report("#{yjit_label}: property access") do
|
|
69
|
-
decls = Cataract::Declarations.new
|
|
70
|
-
decls['color'] = 'red'
|
|
71
|
-
decls['background'] = 'blue'
|
|
72
|
-
decls['font-size'] = '16px'
|
|
73
|
-
decls['margin'] = '10px'
|
|
74
|
-
decls['padding'] = '5px'
|
|
75
|
-
_ = decls['color']
|
|
76
|
-
_ = decls['background']
|
|
77
|
-
_ = decls['font-size']
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def run_declaration_merging_benchmark
|
|
83
|
-
puts "\n#{'=' * 80}"
|
|
84
|
-
puts "TEST: Declaration merging - #{yjit_label}"
|
|
85
|
-
puts '=' * 80
|
|
86
|
-
|
|
87
|
-
benchmark('declaration_merging') do |x|
|
|
88
|
-
x.config(time: 3, warmup: 1)
|
|
89
|
-
|
|
90
|
-
x.report("#{yjit_label}: declaration merging") do
|
|
91
|
-
decls1 = Cataract::Declarations.new
|
|
92
|
-
decls1['color'] = 'red'
|
|
93
|
-
decls1['font-size'] = '16px'
|
|
94
|
-
|
|
95
|
-
decls2 = Cataract::Declarations.new
|
|
96
|
-
decls2['background'] = 'blue'
|
|
97
|
-
decls2['margin'] = '10px'
|
|
98
|
-
|
|
99
|
-
decls1.merge(decls2)
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
def run_to_s_benchmark
|
|
105
|
-
puts "\n#{'=' * 80}"
|
|
106
|
-
puts "TEST: to_s generation - #{yjit_label}"
|
|
107
|
-
puts '=' * 80
|
|
108
|
-
|
|
109
|
-
benchmark('to_s') do |x|
|
|
110
|
-
x.config(time: 3, warmup: 1)
|
|
111
|
-
|
|
112
|
-
x.report("#{yjit_label}: to_s generation") do
|
|
113
|
-
decls = Cataract::Declarations.new
|
|
114
|
-
decls['color'] = 'red'
|
|
115
|
-
decls['background'] = 'blue'
|
|
116
|
-
decls['font-size'] = '16px'
|
|
117
|
-
decls['margin'] = '10px'
|
|
118
|
-
decls['padding'] = '5px'
|
|
119
|
-
decls.to_s
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
def run_parse_iterate_benchmark
|
|
125
|
-
puts "\n#{'=' * 80}"
|
|
126
|
-
puts "TEST: Parse + iterate - #{yjit_label}"
|
|
127
|
-
puts '=' * 80
|
|
128
|
-
|
|
129
|
-
benchmark('parse_iterate') do |x|
|
|
130
|
-
x.config(time: 3, warmup: 1)
|
|
131
|
-
|
|
132
|
-
x.report("#{yjit_label}: parse + iterate") do
|
|
133
|
-
parser = Cataract::Stylesheet.new
|
|
134
|
-
parser.add_block(SAMPLE_CSS)
|
|
135
|
-
parser.select(&:selector?).each do |rule|
|
|
136
|
-
_ = rule.declarations
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
end
|