From 5259c31b3618297b7bdffad5f65698f0c2ac78ff Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Mon, 23 Jun 2014 20:49:11 +0200 Subject: [PATCH] Re-organized/cleaned up the benchmarks directory. --- benchmark/xml/lexer/big_xml_io_time.rb | 7 ------- benchmark/xml/lexer/big_xml_time.rb | 9 --------- .../xml/lexer/{cdata.rb => cdata_bench.rb} | 0 .../xml/lexer/{element.rb => element_bench.rb} | 0 benchmark/xml/lexer/{html.rb => html_bench.rb} | 0 benchmark/xml/lexer/html_time.rb | 9 --------- ...ig_xml_io_average.rb => io_average_bench.rb} | 0 benchmark/xml/lexer/lexer_bench.rb | 13 +++++++++++++ benchmark/xml/lexer/line_rate.rb | 17 ----------------- ...g_xml_average.rb => string_average_bench.rb} | 0 .../{big_xml_average.rb => average_bench.rb} | 0 benchmark/xml/parser/big_xml_time.rb | 10 ---------- .../xml/parser/{element.rb => element_bench.rb} | 0 benchmark/xml/parser/{html.rb => html_bench.rb} | 0 benchmark/xml/parser/parser_bench.rb | 13 +++++++++++++ .../{big_xml_average.rb => average_bench.rb} | 0 benchmark/xml/pull_parser/big_xml_time.rb | 10 ---------- benchmark/xml/pull_parser/pull_parser_bench.rb | 13 +++++++++++++ .../xpath/lexer/{simple.rb => lexer_bench.rb} | 4 ++-- benchmark/xpath/lexer/simple_time.rb | 9 --------- 20 files changed, 41 insertions(+), 73 deletions(-) delete mode 100644 benchmark/xml/lexer/big_xml_io_time.rb delete mode 100644 benchmark/xml/lexer/big_xml_time.rb rename benchmark/xml/lexer/{cdata.rb => cdata_bench.rb} (100%) rename benchmark/xml/lexer/{element.rb => element_bench.rb} (100%) rename benchmark/xml/lexer/{html.rb => html_bench.rb} (100%) delete mode 100644 benchmark/xml/lexer/html_time.rb rename benchmark/xml/lexer/{big_xml_io_average.rb => io_average_bench.rb} (100%) create mode 100644 benchmark/xml/lexer/lexer_bench.rb delete mode 100644 benchmark/xml/lexer/line_rate.rb rename benchmark/xml/lexer/{big_xml_average.rb => string_average_bench.rb} (100%) rename benchmark/xml/parser/{big_xml_average.rb => average_bench.rb} (100%) delete mode 100644 benchmark/xml/parser/big_xml_time.rb rename benchmark/xml/parser/{element.rb => element_bench.rb} (100%) rename benchmark/xml/parser/{html.rb => html_bench.rb} (100%) create mode 100644 benchmark/xml/parser/parser_bench.rb rename benchmark/xml/pull_parser/{big_xml_average.rb => average_bench.rb} (100%) delete mode 100644 benchmark/xml/pull_parser/big_xml_time.rb create mode 100644 benchmark/xml/pull_parser/pull_parser_bench.rb rename benchmark/xpath/lexer/{simple.rb => lexer_bench.rb} (65%) delete mode 100644 benchmark/xpath/lexer/simple_time.rb diff --git a/benchmark/xml/lexer/big_xml_io_time.rb b/benchmark/xml/lexer/big_xml_io_time.rb deleted file mode 100644 index 7c8490e..0000000 --- a/benchmark/xml/lexer/big_xml_io_time.rb +++ /dev/null @@ -1,7 +0,0 @@ -require_relative '../../benchmark_helper' - -Benchmark.bmbm(10) do |bench| - bench.report '10MB of XML using IO' do - Oga::XML::Lexer.new(big_xml_file).advance { |tok| } - end -end diff --git a/benchmark/xml/lexer/big_xml_time.rb b/benchmark/xml/lexer/big_xml_time.rb deleted file mode 100644 index 73251f9..0000000 --- a/benchmark/xml/lexer/big_xml_time.rb +++ /dev/null @@ -1,9 +0,0 @@ -require_relative '../../benchmark_helper' - -xml = read_big_xml - -Benchmark.bmbm(10) do |bench| - bench.report '10MB of XML' do - Oga::XML::Lexer.new(xml).advance { |tok| } - end -end diff --git a/benchmark/xml/lexer/cdata.rb b/benchmark/xml/lexer/cdata_bench.rb similarity index 100% rename from benchmark/xml/lexer/cdata.rb rename to benchmark/xml/lexer/cdata_bench.rb diff --git a/benchmark/xml/lexer/element.rb b/benchmark/xml/lexer/element_bench.rb similarity index 100% rename from benchmark/xml/lexer/element.rb rename to benchmark/xml/lexer/element_bench.rb diff --git a/benchmark/xml/lexer/html.rb b/benchmark/xml/lexer/html_bench.rb similarity index 100% rename from benchmark/xml/lexer/html.rb rename to benchmark/xml/lexer/html_bench.rb diff --git a/benchmark/xml/lexer/html_time.rb b/benchmark/xml/lexer/html_time.rb deleted file mode 100644 index 97fad67..0000000 --- a/benchmark/xml/lexer/html_time.rb +++ /dev/null @@ -1,9 +0,0 @@ -require_relative '../../benchmark_helper' - -html = read_html - -Benchmark.bmbm(20) do |bench| - bench.report 'lex HTML' do - Oga::XML::Lexer.new(html, :html => true).lex - end -end diff --git a/benchmark/xml/lexer/big_xml_io_average.rb b/benchmark/xml/lexer/io_average_bench.rb similarity index 100% rename from benchmark/xml/lexer/big_xml_io_average.rb rename to benchmark/xml/lexer/io_average_bench.rb diff --git a/benchmark/xml/lexer/lexer_bench.rb b/benchmark/xml/lexer/lexer_bench.rb new file mode 100644 index 0000000..324aa3b --- /dev/null +++ b/benchmark/xml/lexer/lexer_bench.rb @@ -0,0 +1,13 @@ +require_relative '../../benchmark_helper' + +xml = read_big_xml + +Benchmark.ips do |bench| + bench.report '10MB as a String' do + Oga::XML::Lexer.new(xml).advance { } + end + + bench.report '10MB as an IO' do + Oga::XML::Lexer.new(big_xml_file).advance { } + end +end diff --git a/benchmark/xml/lexer/line_rate.rb b/benchmark/xml/lexer/line_rate.rb deleted file mode 100644 index 20f334f..0000000 --- a/benchmark/xml/lexer/line_rate.rb +++ /dev/null @@ -1,17 +0,0 @@ -require_relative '../../benchmark_helper' - -xml = read_big_xml -lines = xml.lines.count -lexer = Oga::XML::Lexer.new(xml) -timings = Benchmark.bm(20) do |bench| - bench.report("#{lines} lines") do - lexer.advance { |_| } - lexer.reset - end -end - -time = timings[0].real -rate = lines / time - -puts -puts "Lines/second: #{rate.round(3)}" diff --git a/benchmark/xml/lexer/big_xml_average.rb b/benchmark/xml/lexer/string_average_bench.rb similarity index 100% rename from benchmark/xml/lexer/big_xml_average.rb rename to benchmark/xml/lexer/string_average_bench.rb diff --git a/benchmark/xml/parser/big_xml_average.rb b/benchmark/xml/parser/average_bench.rb similarity index 100% rename from benchmark/xml/parser/big_xml_average.rb rename to benchmark/xml/parser/average_bench.rb diff --git a/benchmark/xml/parser/big_xml_time.rb b/benchmark/xml/parser/big_xml_time.rb deleted file mode 100644 index da3d7ca..0000000 --- a/benchmark/xml/parser/big_xml_time.rb +++ /dev/null @@ -1,10 +0,0 @@ -require_relative '../../benchmark_helper' - -xml = read_big_xml -parser = Oga::XML::Parser.new(xml) - -Benchmark.bmbm(10) do |bench| - bench.report '10MB of XML' do - parser.parse - end -end diff --git a/benchmark/xml/parser/element.rb b/benchmark/xml/parser/element_bench.rb similarity index 100% rename from benchmark/xml/parser/element.rb rename to benchmark/xml/parser/element_bench.rb diff --git a/benchmark/xml/parser/html.rb b/benchmark/xml/parser/html_bench.rb similarity index 100% rename from benchmark/xml/parser/html.rb rename to benchmark/xml/parser/html_bench.rb diff --git a/benchmark/xml/parser/parser_bench.rb b/benchmark/xml/parser/parser_bench.rb new file mode 100644 index 0000000..87553d2 --- /dev/null +++ b/benchmark/xml/parser/parser_bench.rb @@ -0,0 +1,13 @@ +require_relative '../../benchmark_helper' + +xml = read_big_xml + +Benchmark.ips do |bench| + bench.report '10MB as a String' do + Oga::XML::Parser.new(xml).parse + end + + bench.report '10MB as an IO' do + Oga::XML::Parser.new(big_xml_file).parse + end +end diff --git a/benchmark/xml/pull_parser/big_xml_average.rb b/benchmark/xml/pull_parser/average_bench.rb similarity index 100% rename from benchmark/xml/pull_parser/big_xml_average.rb rename to benchmark/xml/pull_parser/average_bench.rb diff --git a/benchmark/xml/pull_parser/big_xml_time.rb b/benchmark/xml/pull_parser/big_xml_time.rb deleted file mode 100644 index 197df00..0000000 --- a/benchmark/xml/pull_parser/big_xml_time.rb +++ /dev/null @@ -1,10 +0,0 @@ -require_relative '../../benchmark_helper' - -xml = read_big_xml -parser = Oga::XML::PullParser.new(xml) - -Benchmark.bmbm(10) do |bench| - bench.report '10MB of XML' do - parser.parse { |node| } - end -end diff --git a/benchmark/xml/pull_parser/pull_parser_bench.rb b/benchmark/xml/pull_parser/pull_parser_bench.rb new file mode 100644 index 0000000..def32b9 --- /dev/null +++ b/benchmark/xml/pull_parser/pull_parser_bench.rb @@ -0,0 +1,13 @@ +require_relative '../../benchmark_helper' + +xml = read_big_xml + +Benchmark.ips do |bench| + bench.report '10MB as a String' do + Oga::XML::PullParser.new(xml).parse { } + end + + bench.report '10MB as an IO' do + Oga::XML::PullParser.new(big_xml_file).parse { } + end +end diff --git a/benchmark/xpath/lexer/simple.rb b/benchmark/xpath/lexer/lexer_bench.rb similarity index 65% rename from benchmark/xpath/lexer/simple.rb rename to benchmark/xpath/lexer/lexer_bench.rb index f0f6734..37d1310 100644 --- a/benchmark/xpath/lexer/simple.rb +++ b/benchmark/xpath/lexer/lexer_bench.rb @@ -3,7 +3,7 @@ require_relative '../../benchmark_helper' xpath = '/wikimedia/projects/project[@name="Wikipedia"]/editions/edition/text()' Benchmark.ips do |bench| - bench.report 'simple XPath' do - Oga::XPath::Lexer.new(xpath).lex + bench.report 'Wikipedia example' do + Oga::XPath::Lexer.new(xpath).advance { } end end diff --git a/benchmark/xpath/lexer/simple_time.rb b/benchmark/xpath/lexer/simple_time.rb deleted file mode 100644 index 84cb694..0000000 --- a/benchmark/xpath/lexer/simple_time.rb +++ /dev/null @@ -1,9 +0,0 @@ -require_relative '../../benchmark_helper' - -xpath = '/wikimedia/projects/project[@name="Wikipedia"]/editions/edition/text()' - -Benchmark.bmbm(10) do |bench| - bench.report 'simple XPath' do - Oga::XPath::Lexer.new(xpath).lex - end -end