Skip to content

Instantly share code, notes, and snippets.

@jcalvert
Created March 13, 2018 13:20
Show Gist options
  • Save jcalvert/0c67997da37191f7b06fb26affdfce6b to your computer and use it in GitHub Desktop.
Save jcalvert/0c67997da37191f7b06fb26affdfce6b to your computer and use it in GitHub Desktop.
Failing greeter
this_dir = File.expand_path(File.dirname(__FILE__))
lib_dir = File.join(this_dir, 'lib')
$LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
require 'grpc'
require 'helloworld_services_pb'
def main
user = ARGV.size > 0 ? ARGV[0] : 'world'
sup = Time.now.to_f
stub = Helloworld::Greeter::Stub.new('www.example.com:2000', :this_channel_is_insecure)
100.times do |i|
start = Time.now.to_f
begin
message = stub.say_hello(Helloworld::HelloRequest.new(name: user), deadline: start+0.2).message
rescue => e
ensure
puts "Excessive Running time iteration #{i}!: #{Time.now.to_f - start}, total: #{sup-Time.now.to_f}" if (Time.now.to_f - start) > 1
end
end
end
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment