diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-10-08 16:22:43 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-10-08 16:22:43 +0200 |
commit | 69bcef32e12cca8a4a31c3035509d479a712b504 (patch) | |
tree | 7ff4b1e444ba1ba470f5f2da29f168b3e487c672 /spec/benchmarks | |
parent | a2374758e34475ebdfacbe68b6c5b095b66262ec (diff) | |
parent | 4841e883020146fecd386caff7f31f2d9cf307b6 (diff) | |
download | gitlab-ce-69bcef32e12cca8a4a31c3035509d479a712b504.tar.gz |
Merge remote-tracking branch 'public/trending-projects-performance'
Diffstat (limited to 'spec/benchmarks')
-rw-r--r-- | spec/benchmarks/finders/trending_projects_finder_spec.rb | 14 | ||||
-rw-r--r-- | spec/benchmarks/models/project_spec.rb | 33 |
2 files changed, 47 insertions, 0 deletions
diff --git a/spec/benchmarks/finders/trending_projects_finder_spec.rb b/spec/benchmarks/finders/trending_projects_finder_spec.rb new file mode 100644 index 00000000000..551ce21840d --- /dev/null +++ b/spec/benchmarks/finders/trending_projects_finder_spec.rb @@ -0,0 +1,14 @@ +require 'spec_helper' + +describe TrendingProjectsFinder, benchmark: true do + describe '#execute' do + let(:finder) { described_class.new } + let(:user) { create(:user) } + + # to_a is used to force actually running the query (instead of just building + # it). + benchmark_subject { finder.execute(user).non_archived.to_a } + + it { is_expected.to iterate_per_second(500) } + end +end diff --git a/spec/benchmarks/models/project_spec.rb b/spec/benchmarks/models/project_spec.rb new file mode 100644 index 00000000000..f1dd10440a9 --- /dev/null +++ b/spec/benchmarks/models/project_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper' + +describe Project, benchmark: true do + describe '.trending' do + let(:group) { create(:group) } + let(:project1) { create(:empty_project, :public, group: group) } + let(:project2) { create(:empty_project, :public, group: group) } + + let(:iterations) { 500 } + + before do + 2.times do + create(:note_on_commit, project: project1) + end + + create(:note_on_commit, project: project2) + end + + describe 'without an explicit start date' do + benchmark_subject { described_class.trending.to_a } + + it { is_expected.to iterate_per_second(iterations) } + end + + describe 'with an explicit start date' do + let(:date) { 1.month.ago } + + benchmark_subject { described_class.trending(date).to_a } + + it { is_expected.to iterate_per_second(iterations) } + end + end +end |