|
| 1 | +# Licensed to Elasticsearch B.V. under one or more contributor |
| 2 | +# license agreements. See the NOTICE file distributed with |
| 3 | +# this work for additional information regarding copyright |
| 4 | +# ownership. Elasticsearch B.V. licenses this file to you under |
| 5 | +# the Apache License, Version 2.0 (the "License"); you may |
| 6 | +# not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | + |
| 18 | +require_relative "../benchmarking" |
| 19 | + |
| 20 | +namespace :benchmark do |
| 21 | + |
| 22 | + namespace :simple do |
| 23 | + |
| 24 | + desc "Run the \'ping\' benchmark test" |
| 25 | + task :ping do |
| 26 | + Elasticsearch::Benchmarking.each_run(ENV['matrix']) do |run| |
| 27 | + task = Elasticsearch::Benchmarking::Simple.new(run) |
| 28 | + puts "PING: " |
| 29 | + puts "#{task.run(:ping)}" |
| 30 | + end |
| 31 | + end |
| 32 | + |
| 33 | + desc "Run the \'create index\' benchmark test" |
| 34 | + task :create_index do |
| 35 | + Elasticsearch::Benchmarking.each_run(ENV['matrix']) do |run| |
| 36 | + task = Elasticsearch::Benchmarking::Simple.new(run) |
| 37 | + puts "CREATE INDEX: #{task.run(:create_index)}" |
| 38 | + end |
| 39 | + end |
| 40 | + |
| 41 | + desc "Run the \'index smal document\' benchmark test with patron adapter" |
| 42 | + task :index_document_small_patron do |
| 43 | + Elasticsearch::Benchmarking.each_run(ENV['matrix']) do |run| |
| 44 | + begin |
| 45 | + require 'patron' |
| 46 | + rescue LoadError |
| 47 | + puts "Patron not loaded, skipping test" |
| 48 | + else |
| 49 | + task = Elasticsearch::Benchmarking::Simple.new(run, :patron) |
| 50 | + puts "INDEX SMALL DOCUMENT, PATRON: #{task.run(:index_document_small)}" |
| 51 | + end |
| 52 | + end |
| 53 | + end |
| 54 | + |
| 55 | + desc "Run the \'index small document\' benchmark test" |
| 56 | + task :index_document_small do |
| 57 | + Elasticsearch::Benchmarking.each_run(ENV['matrix']) do |run| |
| 58 | + task = Elasticsearch::Benchmarking::Simple.new(run) |
| 59 | + puts "INDEX SMALL DOCUMENT: #{task.run(:index_document_small)}" |
| 60 | + end |
| 61 | + end |
| 62 | + |
| 63 | + desc "Run the \'index large document\' benchmark test" |
| 64 | + task :index_document_large do |
| 65 | + Elasticsearch::Benchmarking.each_run(ENV['matrix']) do |run| |
| 66 | + task = Elasticsearch::Benchmarking::Simple.new(run) |
| 67 | + puts "INDEX LARGE DOCUMENT: #{task.run(:index_document_large)}" |
| 68 | + end |
| 69 | + end |
| 70 | + |
| 71 | + desc "Run the \'get small document\' benchmark test" |
| 72 | + task :get_document_small do |
| 73 | + Elasticsearch::Benchmarking.each_run(ENV['matrix']) do |run| |
| 74 | + task = Elasticsearch::Benchmarking::Simple.new(run) |
| 75 | + puts "GET SMALL DOCUMENT: #{task.run(:get_document_small)}" |
| 76 | + end |
| 77 | + end |
| 78 | + |
| 79 | + desc "Run the \'get large document\' benchmark test" |
| 80 | + task :get_document_large do |
| 81 | + Elasticsearch::Benchmarking.each_run(ENV['matrix']) do |run| |
| 82 | + task = Elasticsearch::Benchmarking::Simple.new(run) |
| 83 | + puts "GET LARGE DOCUMENT: #{task.run(:get_document_large)}" |
| 84 | + end |
| 85 | + end |
| 86 | + |
| 87 | + desc "Run the \'search small document\' benchmark test" |
| 88 | + task :search_document_small do |
| 89 | + Elasticsearch::Benchmarking.each_run(ENV['matrix']) do |run| |
| 90 | + task = Elasticsearch::Benchmarking::Simple.new(run) |
| 91 | + puts "SEARCH SMALL DOCUMENT: #{task.run(:search_document_small)}" |
| 92 | + end |
| 93 | + end |
| 94 | + |
| 95 | + desc "Run the \'search small document\' benchmark test" |
| 96 | + task :search_document_large do |
| 97 | + Elasticsearch::Benchmarking.each_run(ENV['matrix']) do |run| |
| 98 | + task = Elasticsearch::Benchmarking::Simple.new(run) |
| 99 | + puts "SEARCH LARGE DOCUMENT: #{task.run(:search_document_large)}" |
| 100 | + end |
| 101 | + end |
| 102 | + |
| 103 | + desc "Run the \'update document\' benchmark test" |
| 104 | + task :update_document do |
| 105 | + Elasticsearch::Benchmarking.each_run(ENV['matrix']) do |run| |
| 106 | + task = Elasticsearch::Benchmarking::Simple.new(run) |
| 107 | + puts "UPDATE DOCUMENT: #{task.run(:update_document)}" |
| 108 | + end |
| 109 | + end |
| 110 | + |
| 111 | + desc "Run all simple benchmark tests" |
| 112 | + task :all, [:matrix] do |t, args| |
| 113 | + %w[ benchmark:simple:ping |
| 114 | + benchmark:simple:create_index |
| 115 | + benchmark:simple:index_document_small |
| 116 | + benchmark:simple:index_document_small_patron |
| 117 | + benchmark:simple:index_document_large |
| 118 | + benchmark:simple:get_document_small |
| 119 | + benchmark:simple:get_document_large |
| 120 | + benchmark:simple:search_document_small |
| 121 | + benchmark:simple:search_document_large |
| 122 | + benchmark:simple:update_document |
| 123 | + ].each do |task_name| |
| 124 | + begin |
| 125 | + Rake::Task[task_name].invoke(*args) |
| 126 | + rescue => ex |
| 127 | + puts "Error in task [#{task_name}], #{ex.inspect}" |
| 128 | + next |
| 129 | + end |
| 130 | + end |
| 131 | + end |
| 132 | + |
| 133 | + # namespace :noop do |
| 134 | + # |
| 135 | + # desc "Run the \'search small document\' benchmark test with the noop plugin" |
| 136 | + # task :search_document_small do |
| 137 | + # puts "SIMPLE REQUEST BENCHMARK:: SEARCH SMALL DOCUMENT WITH NOOP PLUGIN" |
| 138 | + # Elasticsearch::Benchmarking::Simple.new.run(:search_document_small, noop: true) |
| 139 | + # end |
| 140 | + # end |
| 141 | + end |
| 142 | + |
| 143 | + namespace :complex do |
| 144 | + |
| 145 | + desc "Run the \'index documents\' benchmark test" |
| 146 | + task :index_documents do |
| 147 | + Elasticsearch::Benchmarking.each_run(ENV['matrix']) do |run| |
| 148 | + task = Elasticsearch::Benchmarking::Complex.new(run) |
| 149 | + puts "INDEX DOCUMENTS: #{task.run(:index_documents)}" |
| 150 | + end |
| 151 | + end |
| 152 | + |
| 153 | + desc "Run the \'search documents\' benchmark test" |
| 154 | + task :search_documents do |
| 155 | + Elasticsearch::Benchmarking.each_run(ENV['matrix']) do |run| |
| 156 | + task = Elasticsearch::Benchmarking::Complex.new(run) |
| 157 | + puts "SEARCH DOCUMENTS: #{task.run(:search_documents)}" |
| 158 | + end |
| 159 | + end |
| 160 | + |
| 161 | + desc "Run all complex benchmark test" |
| 162 | + task :all do |
| 163 | + %w[ benchmark:complex:index_documents |
| 164 | + ].each do |task_name| |
| 165 | + Rake::Task[task_name].invoke |
| 166 | + end |
| 167 | + end |
| 168 | + end |
| 169 | +end |
0 commit comments