diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2015-10-20 15:51:02 +0200 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2015-10-20 15:53:22 +0200 |
commit | e1c3077e4bb718ce841fad175f708623d8375818 (patch) | |
tree | ff82bc7da0f4b46f41075cf05d4e6ab81373bdc4 | |
parent | afdc028516f27651d4d94ffd568765cf640c0c44 (diff) | |
download | gitlab-ce-e1c3077e4bb718ce841fad175f708623d8375818.tar.gz |
Added benchmark for ReferenceFilterreference-filter-replace-text-nodes-performance
-rw-r--r-- | spec/benchmarks/lib/gitlab/markdown/reference_filter_spec.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/benchmarks/lib/gitlab/markdown/reference_filter_spec.rb b/spec/benchmarks/lib/gitlab/markdown/reference_filter_spec.rb new file mode 100644 index 00000000000..34cd9f7e4eb --- /dev/null +++ b/spec/benchmarks/lib/gitlab/markdown/reference_filter_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper' + +describe Gitlab::Markdown::ReferenceFilter, benchmark: true do + let(:input) do + html = <<-EOF +<p>Hello @alice and @bob, how are you doing today?</p> +<p>This is simple @dummy text to see how the @ReferenceFilter class performs +when @processing HTML.</p> + EOF + + Nokogiri::HTML.fragment(html) + end + + let(:project) { create(:empty_project) } + + let(:filter) { described_class.new(input, project: project) } + + describe '#replace_text_nodes_matching' do + let(:iterations) { 6000 } + + describe 'with identical input and output HTML' do + benchmark_subject do + filter.replace_text_nodes_matching(User.reference_pattern) do |content| + content + end + end + + it { is_expected.to iterate_per_second(iterations) } + end + + describe 'with different input and output HTML' do + benchmark_subject do + filter.replace_text_nodes_matching(User.reference_pattern) do |content| + '@eve' + end + end + + it { is_expected.to iterate_per_second(iterations) } + end + end +end |