lib/honeydew/device.rb in honeydew-0.18.0 vs lib/honeydew/device.rb in honeydew-0.19.0
- old
+ new
@@ -54,22 +54,35 @@
uri = device_endpoint('/command')
request = Net::HTTP::Post.new uri.path
request.set_form_data action: action, arguments: arguments.to_json.to_s
- response = Net::HTTP.start(uri.hostname, uri.port) do |http|
- http.read_timeout = Honeydew.config.server_timeout
- http.request request
+ response = benchmark do
+ Net::HTTP.start(uri.hostname, uri.port) do |http|
+ http.read_timeout = Honeydew.config.server_timeout
+ http.request request
+ end
end
case response
when Net::HTTPOK
- true
+ info "action succeeded, response: #{response.body}"
+ response.body
when Net::HTTPNoContent
+ info "action failed, response: #{response.body}"
raise ActionFailedError.new response.body
else
raise "honeydew-server failed to process command, response: #{response.body}"
end
+ end
+
+ def benchmark
+ result = nil
+ realtime = Benchmark.realtime do
+ result = yield
+ end
+ debug "action completed in #{(realtime * 1000).to_i}ms"
+ result
end
def ensure_device_ready
@device_ready ||= begin
wait_for_honeydew_server