diff --git a/profile/benchmarking/complex.rb b/profile/benchmarking/complex.rb index f04f72e844..4f08e71fae 100644 --- a/profile/benchmarking/complex.rb +++ b/profile/benchmarking/complex.rb @@ -48,7 +48,7 @@ def index_documents(opts = {}) end with_cleanup do - start = Process.clock_gettime(Process::CLOCK_MONOTONIC) + start = current_time results = measured_repetitions.times.collect do Benchmark.realtime do slices.each do |slice| @@ -56,7 +56,7 @@ def index_documents(opts = {}) end end end - end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) + end_time = current_time results end @@ -96,13 +96,13 @@ def search_documents(opts = {}) client.search(request) end - start = Process.clock_gettime(Process::CLOCK_MONOTONIC) + start = current_time results = measured_repetitions.times.collect do Benchmark.realtime do client.search(request) end end - end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) + end_time = current_time results end diff --git a/profile/benchmarking/measurable.rb b/profile/benchmarking/measurable.rb index aa2fc8deb7..49441f9774 100644 --- a/profile/benchmarking/measurable.rb +++ b/profile/benchmarking/measurable.rb @@ -282,6 +282,11 @@ def result_cluster_client Elasticsearch::Client.new(opts) end end + + def current_time + # Use monotonic time to provide problems with leap seconds, time changes, syncs etc. + Process.clock_gettime(Process::CLOCK_MONOTONIC) + end end end end diff --git a/profile/benchmarking/simple.rb b/profile/benchmarking/simple.rb index d0f0c66742..e0415d9341 100644 --- a/profile/benchmarking/simple.rb +++ b/profile/benchmarking/simple.rb @@ -45,7 +45,7 @@ def ping(opts = {}) warmup_repetitions.times { client.ping } - start = Process.clock_gettime(Process::CLOCK_MONOTONIC) + start = current_time results = measured_repetitions.times.collect do Benchmark.realtime do action_iterations.times do @@ -53,7 +53,7 @@ def ping(opts = {}) end end end - end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) + end_time = current_time options = { duration: end_time - start, operation: __method__, @@ -82,7 +82,7 @@ def create_index(opts = {}) end with_cleanup do - start = Process.clock_gettime(Process::CLOCK_MONOTONIC) + start = current_time results = measured_repetitions.times.collect do Benchmark.realtime do action_iterations.times do @@ -90,7 +90,7 @@ def create_index(opts = {}) end end end - end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) + end_time = current_time results end @@ -122,7 +122,7 @@ def index_document_small(opts={}) end with_cleanup do - start = Process.clock_gettime(Process::CLOCK_MONOTONIC) + start = current_time results = measured_repetitions.times.collect do Benchmark.realtime do action_iterations.times do @@ -130,7 +130,7 @@ def index_document_small(opts={}) end end end - end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) + end_time = current_time results end @@ -165,7 +165,7 @@ def index_document_large(opts={}) end with_cleanup do - start = Process.clock_gettime(Process::CLOCK_MONOTONIC) + start = current_time results = measured_repetitions.times.collect do Benchmark.realtime do action_iterations.times do @@ -173,7 +173,7 @@ def index_document_large(opts={}) end end end - end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) + end_time = current_time results end @@ -208,7 +208,7 @@ def get_document_small(opts={}) client.get(index: INDEX, id: id) end - start = Process.clock_gettime(Process::CLOCK_MONOTONIC) + start = current_time results = measured_repetitions.times.collect do Benchmark.realtime do action_iterations.times do @@ -216,7 +216,7 @@ def get_document_small(opts={}) end end end - end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) + end_time = current_time results end @@ -251,7 +251,7 @@ def get_document_large(opts={}) client.get(index: INDEX, id: id) end - start = Process.clock_gettime(Process::CLOCK_MONOTONIC) + start = current_time results = measured_repetitions.times.collect do Benchmark.realtime do action_iterations.times do @@ -259,7 +259,7 @@ def get_document_large(opts={}) end end end - end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) + end_time = current_time end options = { duration: end_time - start, @@ -301,7 +301,7 @@ def search_document_small(opts={}) client.search(request) end - start = Process.clock_gettime(Process::CLOCK_MONOTONIC) + start = current_time results = measured_repetitions.times.collect do Benchmark.realtime do action_iterations.times do @@ -309,7 +309,7 @@ def search_document_small(opts={}) end end end - end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) + end_time = current_time end options = { duration: end_time - start, @@ -350,7 +350,7 @@ def search_document_large(opts={}) client.search(request) end - start = Process.clock_gettime(Process::CLOCK_MONOTONIC) + start = current_time results = measured_repetitions.times.collect do Benchmark.realtime do action_iterations.times do @@ -358,7 +358,7 @@ def search_document_large(opts={}) end end end - end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) + end_time = current_time results end @@ -398,7 +398,7 @@ def update_document(opts={}) body: { doc: { field: "#{document[field]}-#{i}" } }) end - start = Process.clock_gettime(Process::CLOCK_MONOTONIC) + start = current_time results = measured_repetitions.times.collect do Benchmark.realtime do action_iterations.times do |i| @@ -408,7 +408,7 @@ def update_document(opts={}) end end end - end_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) + end_time = current_time results end