Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ GEM
remote: https://rubygems.org/
specs:
ast (2.4.3)
benchmark-ips (2.15.1)
bundler-audit (0.9.3)
bundler (>= 1.2.0)
thor (~> 1.0)
Expand Down Expand Up @@ -82,6 +83,7 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
benchmark-ips
bundler-audit
colorize
html2text!
Expand Down
17 changes: 17 additions & 0 deletions bench/convert.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

# Usage: bundle exec ruby bench/convert.rb
#
# Compare branches by running it on each. The sibling divs case guards against
# the quadratic slowdown fixed in #45.

require 'benchmark/ips'
require_relative '../lib/html2text'

examples = Dir[File.join(__dir__, '../spec/examples/*.html')].map { |f| File.read(f) }
sibling_divs = "<div>#{'<div>x</div>' * 2000}</div>"

Benchmark.ips do |x|
x.report('all spec examples') { examples.each { |html| Html2Text.convert(html) } }
x.report('2000 sibling divs') { Html2Text.convert(sibling_divs) }
end
1 change: 1 addition & 0 deletions html2text.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Gem::Specification.new do |s|

s.add_dependency 'nokogiri', ['>= 1.0', '< 2.0']

s.add_development_dependency 'benchmark-ips'
s.add_development_dependency 'bundler-audit'
s.add_development_dependency 'colorize'
s.add_development_dependency 'rake'
Expand Down