Added CSS/XPath Parser.parse_with_cache

This method parses and caches ASTs using Oga::LRU. Currently the default
of 1024 keys is used.

See #71 for more information.
This commit is contained in:
Yorick Peterse committed 2015-03-23 00:22:59 +01:00
1 parent 67d7d9af88
commit 2c4e490614
6 files changed
+94 -2

No files matched your search

+7 -1
View File
@@ -3,7 +3,13 @@ require_relative '../../benchmark_helper'
css = 'foo bar bar.some_class element#with_id[title="Foo"]'
Benchmark.ips do |bench|
bench.report 'CSS' do
bench.report 'without cache' do
Oga::CSS::Parser.new(css).parse
end
bench.report 'with cache' do
Oga::CSS::Parser.parse_with_cache(css)
end
bench.compare!
end