diff --git a/benchmark/parser/bench_element.rb b/benchmark/parser/bench_element.rb new file mode 100644 index 0000000..44ecddd --- /dev/null +++ b/benchmark/parser/bench_element.rb @@ -0,0 +1,20 @@ +require_relative '../../lib/oga' +require 'benchmark/ips' + +simple = '
Hello world
' +attributes = 'Hello world
' +nested = 'Helloworld
' + +Benchmark.ips do |bench| + bench.report 'text only' do + Oga::XML::Parser.new(simple).parse + end + + bench.report 'text + attributes' do + Oga::XML::Parser.new(attributes).parse + end + + bench.report 'text + children' do + Oga::XML::Parser.new(nested).parse + end +end diff --git a/benchmark/parser/bench_html.rb b/benchmark/parser/bench_html.rb new file mode 100644 index 0000000..954a9cd --- /dev/null +++ b/benchmark/parser/bench_html.rb @@ -0,0 +1,10 @@ +require_relative '../../lib/oga' +require 'benchmark/ips' + +html = File.read(File.expand_path('../../fixtures/hrs.html', __FILE__)) + +Benchmark.ips do |bench| + bench.report 'parse HTML' do + Oga::HTML::Parser.new(html).parse + end +end