diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2015-11-11 12:48:56 +0100 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2015-11-19 11:48:50 +0100 |
commit | 45840426a79f5ab251caf71400d3e4ed5f5eedbf (patch) | |
tree | d7cba3d0e9b5200c72c2f9b2a7855f34ed6a9fb2 /spec | |
parent | e4ae8b1385eecce2e4438f83017799644a8b92ce (diff) | |
download | gitlab-ce-45840426a79f5ab251caf71400d3e4ed5f5eedbf.tar.gz |
Added benchmark for IssuesFinder
Diffstat (limited to 'spec')
-rw-r--r-- | spec/benchmarks/finders/issues_finder_spec.rb | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/benchmarks/finders/issues_finder_spec.rb b/spec/benchmarks/finders/issues_finder_spec.rb new file mode 100644 index 00000000000..c233fa82cf2 --- /dev/null +++ b/spec/benchmarks/finders/issues_finder_spec.rb @@ -0,0 +1,55 @@ +require 'spec_helper' + +describe IssuesFinder, benchmark: true do + describe '#execute' do + let(:user) { create(:user) } + let(:project) { create(:project, :public) } + + let(:label1) { create(:label, project: project, title: 'A') } + let(:label2) { create(:label, project: project, title: 'B') } + + before do + 10.times do |n| + issue = create(:issue, author: user, project: project) + + if n > 4 + create(:label_link, label: label1, target: issue) + create(:label_link, label: label2, target: issue) + end + end + end + + describe 'retrieving issues without labels' do + let(:finder) do + IssuesFinder.new(user, scope: 'all', label_name: Label::None.title, + state: 'opened') + end + + benchmark_subject { finder.execute } + + it { is_expected.to iterate_per_second(2000) } + end + + describe 'retrieving issues with labels' do + let(:finder) do + IssuesFinder.new(user, scope: 'all', label_name: label1.title, + state: 'opened') + end + + benchmark_subject { finder.execute } + + it { is_expected.to iterate_per_second(1000) } + end + + describe 'retrieving issues for a single project' do + let(:finder) do + IssuesFinder.new(user, scope: 'all', label_name: Label::None.title, + state: 'opened', project_id: project.id) + end + + benchmark_subject { finder.execute } + + it { is_expected.to iterate_per_second(2000) } + end + end +end |