Skip to content

Commit

Permalink
Don't measure preparation time
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Feb 6, 2024
1 parent ee39473 commit d494173
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 32 deletions.
4 changes: 2 additions & 2 deletions lib/grntest/base-result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ def measure
ensure
cpu_finish_time = Process.times
real_finish_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
@cpu_elapsed_time =
@cpu_elapsed_time +=
(cpu_finish_time.utime - cpu_start_time.utime) +
(cpu_finish_time.stime - cpu_start_time.stime) +
(cpu_finish_time.cutime - cpu_start_time.cutime) +
(cpu_finish_time.cstime - cpu_start_time.cstime)
@real_elapsed_time = real_finish_time - real_start_time
@real_elapsed_time += real_finish_time - real_start_time
end
end
end
8 changes: 3 additions & 5 deletions lib/grntest/executors/base-executor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -646,11 +646,9 @@ def execute_command(command)
timeout = @context.timeout
response = nil
begin
@benchmark_result.measure do
@benchmark_result.n_iterations.times do
Timeout.timeout(timeout) do
response = send_command(command)
end
@benchmark_result.n_iterations.times do
Timeout.timeout(timeout) do
response = send_command(command)
end
end
rescue Timeout::Error
Expand Down
36 changes: 20 additions & 16 deletions lib/grntest/executors/http-executor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,17 @@ def send_load_command(command)
request = Net::HTTP::Post.new(path)
request.content_type = content_type
set_request_body(request, body)
run_http_request(url) do
http = Net::HTTP.new(@host, @port)
http.set_debug_output($stderr) if LOAD_DEBUG
response = http.start do
http.read_timeout = read_timeout
http.request(request)
@benchmark_result.measure do
run_http_request(url) do
http = Net::HTTP.new(@host, @port)
http.set_debug_output($stderr) if LOAD_DEBUG
response = http.start do
http.read_timeout = read_timeout
http.request(request)
end
check_response(response)
normalize_response_data(command, response.body)
end
check_response(response)
normalize_response_data(command, response.body)
end
end

Expand All @@ -150,15 +152,17 @@ def send_normal_command(command)
request = Net::HTTP::Get.new(path_with_query)
end
url = "http://#{@host}:#{@port}#{path_with_query}"
run_http_request(url) do
http = Net::HTTP.new(@host, @port)
http.set_debug_output($stderr) if DEBUG
response = http.start do
http.read_timeout = read_timeout
http.request(request)
@benchmark_result.measure do
run_http_request(url) do
http = Net::HTTP.new(@host, @port)
http.set_debug_output($stderr) if DEBUG
response = http.start do
http.read_timeout = read_timeout
http.request(request)
end
check_response(response)
normalize_response_data(command, response.body)
end
check_response(response)
normalize_response_data(command, response.body)
end
end

Expand Down
20 changes: 11 additions & 9 deletions lib/grntest/executors/standard-io-executor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,18 @@ def send_command(command)
if !command.key?(:output_type) and @output_type
command_line = command_line.sub(/$/, " --output_type #{@output_type}")
end
begin
debug_input(command_line)
@input.print(command_line)
@input.print("\n")
@input.flush
rescue SystemCallError
message = "failed to write to groonga: <#{command_line}>: #{$!}"
raise Error.new(message)
@benchmark_result.measure do
begin
debug_input(command_line)
@input.print(command_line)
@input.print("\n")
@input.flush
rescue SystemCallError
message = "failed to write to groonga: <#{command_line}>: #{$!}"
raise Error.new(message)
end
read_output(command)
end
read_output(command)
end

def ensure_groonga_ready
Expand Down

0 comments on commit d494173

Please sign in to comment.