Sha256: 7e58c6f2d6af2bb7c1cd0cd08bf52b9e42d8be0da6e11bd8d75e180cd657a1f1

Contents?: true

Size: 1.19 KB

Versions: 11

Compression:

Stored size: 1.19 KB

Contents

require 'test_helper'
require 'minitest/benchmark' if ENV["BENCH"]

def markdown(s)
  CommonMarker.render_doc(s).to_html
end

# Disabled by default
# (these are the easy ones -- the evil ones are not disclosed)
if ENV["BENCH"] then
  class PathologicalInputsTest < Minitest::Benchmark
    def setup
    end

    def bench_pathological_1
      assert_performance_linear 0.99 do |n|
        star = '*'  * (n * 10)
        markdown("#{star}#{star}hi#{star}#{star}")
      end
    end

    def bench_pathological_2
      assert_performance_linear 0.99 do |n|
        c = "`t`t`t`t`t`t" * (n * 10)
        markdown(c)
      end
    end

    def bench_pathological_3
      assert_performance_linear 0.99 do |n|
        markdown(" [a]: #{ "A" * n }\n\n#{ "[a][]" * n }\n")
      end
    end

    def bench_pathological_4
      assert_performance_linear 0.5 do |n|
        markdown("#{'[' * n}a#{']' * n}")
      end
    end

    def bench_pathological_5
      assert_performance_linear 0.99 do |n|
        markdown("#{'**a *a ' * n}#{'a* a**' * n}")
      end
    end

    def bench_unbound_recursion
      assert_performance_linear 0.99 do |n|
        markdown(("[" * n) + "foo" + ("](bar)" * n ))
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
commonmarker-0.9.0 test/test_pathological_inputs.rb
commonmarker-0.8.0 test/test_pathological_inputs.rb
commonmarker-0.7.0 test/test_pathological_inputs.rb
commonmarker-0.6.0 test/test_pathological_inputs.rb
commonmarker-0.5.1 test/test_pathological_inputs.rb
commonmarker-0.5.0 test/test_pathological_inputs.rb
commonmarker-0.4.1 test/test_pathological_inputs.rb
commonmarker-0.4.0 test/test_pathological_inputs.rb
commonmarker-0.3.0 test/test_pathological_inputs.rb
commonmarker-0.2.1 test/test_pathological_inputs.rb
commonmarker-0.2.0 test/test_pathological_inputs.rb