From 8ca778184263283ce75b138e66a29a9c9920ad0d Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Thu, 10 Apr 2014 09:55:33 +0200 Subject: [PATCH] Updated the lexer benchmarks. These had to be updated for the API changes of Oga::XML::Lexer. --- benchmark/lexer/bench_cdata.rb | 7 +++---- benchmark/lexer/bench_element.rb | 7 +++---- benchmark/lexer/bench_html.rb | 5 ++--- benchmark/lexer/bench_html_time.rb | 5 ++--- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/benchmark/lexer/bench_cdata.rb b/benchmark/lexer/bench_cdata.rb index fd84b2c..6235a08 100644 --- a/benchmark/lexer/bench_cdata.rb +++ b/benchmark/lexer/bench_cdata.rb @@ -5,18 +5,17 @@ string = 'Hello, how are you doing today?' small = "" medium = "" large = "" -lexer = Oga::XML::Lexer.new Benchmark.ips do |bench| bench.report 'CDATA with a small body' do - lexer.lex(small) + Oga::XML::Lexer.new(small).lex end bench.report 'CDATA with a medium body' do - lexer.lex(medium) + Oga::XML::Lexer.new(medium).lex end bench.report 'CDATA with a large body' do - lexer.lex(large) + Oga::XML::Lexer.new(large).lex end end diff --git a/benchmark/lexer/bench_element.rb b/benchmark/lexer/bench_element.rb index 93a4674..32007a7 100644 --- a/benchmark/lexer/bench_element.rb +++ b/benchmark/lexer/bench_element.rb @@ -4,18 +4,17 @@ require 'benchmark/ips' simple = '

Hello world

' attributes = '

Hello world

' nested = '

Helloworld

' -lexer = Oga::XML::Lexer.new Benchmark.ips do |bench| bench.report 'text only' do - lexer.lex(simple) + Oga::XML::Lexer.new(simple).lex end bench.report 'text + attributes' do - lexer.lex(attributes) + Oga::XML::Lexer.new(attributes).lex end bench.report 'text + children' do - lexer.lex(nested) + Oga::XML::Lexer.new(nested).lex end end diff --git a/benchmark/lexer/bench_html.rb b/benchmark/lexer/bench_html.rb index 213ea80..3d622a4 100644 --- a/benchmark/lexer/bench_html.rb +++ b/benchmark/lexer/bench_html.rb @@ -1,11 +1,10 @@ require_relative '../../lib/oga' require 'benchmark/ips' -html = File.read(File.expand_path('../../fixtures/hrs.html', __FILE__)) -lexer = Oga::XML::Lexer.new(:html => true) +html = File.read(File.expand_path('../../fixtures/hrs.html', __FILE__)) Benchmark.ips do |bench| bench.report 'lex HTML' do - lexer.lex(html) + Oga::XML::Lexer.new(html, :html => true).lex end end diff --git a/benchmark/lexer/bench_html_time.rb b/benchmark/lexer/bench_html_time.rb index 131b203..abf9a3d 100644 --- a/benchmark/lexer/bench_html_time.rb +++ b/benchmark/lexer/bench_html_time.rb @@ -1,11 +1,10 @@ require_relative '../../lib/oga' require 'benchmark' -html = File.read(File.expand_path('../../fixtures/hrs.html', __FILE__)) -lexer = Oga::XML::Lexer.new(:html => true) +html = File.read(File.expand_path('../../fixtures/hrs.html', __FILE__)) Benchmark.bmbm(20) do |bench| bench.report 'lex HTML' do - lexer.lex(html) + Oga::XML::Lexer.new(html, :html => true).lex end end