From 2852afce9b1c0996f9fe5033bf5ed139f2c97ec9 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Fri, 21 Mar 2014 16:59:44 +0100 Subject: [PATCH] Benchmark for measuring CDATA lexing. --- benchmark/lexer/bench_cdata.rb | 22 ++++++++++++++++++++++ oga.gemspec | 1 + 2 files changed, 23 insertions(+) create mode 100644 benchmark/lexer/bench_cdata.rb diff --git a/benchmark/lexer/bench_cdata.rb b/benchmark/lexer/bench_cdata.rb new file mode 100644 index 0000000..7cf11fd --- /dev/null +++ b/benchmark/lexer/bench_cdata.rb @@ -0,0 +1,22 @@ +require_relative '../../lib/oga' +require 'benchmark/ips' + +string = 'Hello, how are you doing today?' +small = "" +medium = "" +large = "" +lexer = Oga::Lexer.new + +Benchmark.ips do |bench| + bench.report 'CDATA with a small body' do + lexer.lex(small) + end + + bench.report 'CDATA with a medium body' do + lexer.lex(medium) + end + + bench.report 'CDATA with a large body' do + lexer.lex(large) + end +end diff --git a/oga.gemspec b/oga.gemspec index 2e940d2..197b047 100644 --- a/oga.gemspec +++ b/oga.gemspec @@ -24,4 +24,5 @@ Gem::Specification.new do |s| s.add_development_dependency 'yard' s.add_development_dependency 'simplecov' s.add_development_dependency 'kramdown' + s.add_development_dependency 'benchmark-ips' end