Cleaned up benchmarking code.
This commit is contained in:
parent
ebf9099f0e
commit
203aea6b1a
|
@ -0,0 +1,22 @@
|
|||
require 'benchmark'
|
||||
require 'benchmark/ips'
|
||||
|
||||
require_relative '../lib/oga'
|
||||
|
||||
##
|
||||
# Reads a big XML file and returns it as a String.
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
def read_big_xml
|
||||
return File.read(File.expand_path('../fixtures/big.xml', __FILE__))
|
||||
end
|
||||
|
||||
##
|
||||
# Reads a normal sized HTML fixture.
|
||||
#
|
||||
# @return [String]
|
||||
#
|
||||
def read_html
|
||||
return File.read(File.expand_path('../fixtures/gist.html', __FILE__))
|
||||
end
|
|
@ -1,7 +1,6 @@
|
|||
require_relative '../../lib/oga'
|
||||
require 'benchmark'
|
||||
require_relative '../benchmark_helper'
|
||||
|
||||
xml = File.read(File.expand_path('../../fixtures/big.xml', __FILE__))
|
||||
xml = read_big_xml
|
||||
amount = 10
|
||||
timings = []
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
require_relative '../../lib/oga'
|
||||
require 'benchmark'
|
||||
require_relative '../benchmark_helper'
|
||||
|
||||
xml = File.read(File.expand_path('../../fixtures/big.xml', __FILE__))
|
||||
xml = read_big_xml
|
||||
|
||||
Benchmark.bmbm(10) do |bench|
|
||||
bench.report '10MB of XML' do
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
require_relative '../../lib/oga'
|
||||
require 'benchmark/ips'
|
||||
require_relative '../benchmark_helper'
|
||||
|
||||
string = 'Hello, how are you doing today?'
|
||||
small = "<![CDATA[#{string}]]>"
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
require_relative '../../lib/oga'
|
||||
require 'benchmark/ips'
|
||||
require_relative '../benchmark_helper'
|
||||
|
||||
simple = '<p>Hello world</p>'
|
||||
attributes = '<p class="foo">Hello world</p>'
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
require_relative '../../lib/oga'
|
||||
require 'benchmark/ips'
|
||||
require_relative '../benchmark_helper'
|
||||
|
||||
html = File.read(File.expand_path('../../fixtures/gist.html', __FILE__))
|
||||
html = read_html
|
||||
|
||||
Benchmark.ips do |bench|
|
||||
bench.report 'lex HTML' do
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
require_relative '../../lib/oga'
|
||||
require 'benchmark'
|
||||
require_relative '../benchmark_helper'
|
||||
|
||||
html = File.read(File.expand_path('../../fixtures/gist.html', __FILE__))
|
||||
html = read_html
|
||||
|
||||
Benchmark.bmbm(20) do |bench|
|
||||
bench.report 'lex HTML' do
|
||||
|
|
|
@ -1,14 +1,6 @@
|
|||
require_relative '../../lib/oga'
|
||||
require 'benchmark'
|
||||
require_relative '../benchmark_helper'
|
||||
|
||||
fixture = File.expand_path('../../fixtures/big.xml', __FILE__)
|
||||
|
||||
unless File.file?(fixture)
|
||||
system('rake fixtures')
|
||||
puts
|
||||
end
|
||||
|
||||
xml = File.read(fixture)
|
||||
xml = read_big_xml
|
||||
lines = xml.lines.count
|
||||
lexer = Oga::XML::Lexer.new(xml)
|
||||
timings = Benchmark.bm(20) do |bench|
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
require_relative '../../lib/oga'
|
||||
require 'benchmark'
|
||||
require_relative '../benchmark_helper'
|
||||
|
||||
xml = File.read(File.expand_path('../../fixtures/big.xml', __FILE__))
|
||||
xml = read_big_xml
|
||||
parser = Oga::XML::Parser.new(xml)
|
||||
|
||||
Benchmark.bmbm(10) do |bench|
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
require_relative '../../lib/oga'
|
||||
require 'benchmark/ips'
|
||||
require_relative '../benchmark_helper'
|
||||
|
||||
simple = '<p>Hello world</p>'
|
||||
attributes = '<p class="foo">Hello world</p>'
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
require_relative '../../lib/oga'
|
||||
require 'benchmark/ips'
|
||||
require_relative '../benchmark_helper'
|
||||
|
||||
html = File.read(File.expand_path('../../fixtures/gist.html', __FILE__))
|
||||
html = read_html
|
||||
|
||||
Benchmark.ips do |bench|
|
||||
bench.report 'parse HTML' do
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
require_relative '../../lib/oga'
|
||||
require 'benchmark'
|
||||
require_relative '../benchmark_helper'
|
||||
|
||||
xml = File.read(File.expand_path('../../fixtures/big.xml', __FILE__))
|
||||
xml = read_big_xml
|
||||
parser = Oga::XML::PullParser.new(xml)
|
||||
|
||||
Benchmark.bmbm(10) do |bench|
|
||||
|
|
Loading…
Reference in New Issue