Initial skeleton of benchmark client and server
diff --git a/src/ruby/qps/worker.rb b/src/ruby/qps/worker.rb
index 2530092..ca60f51 100755
--- a/src/ruby/qps/worker.rb
+++ b/src/ruby/qps/worker.rb
@@ -41,15 +41,49 @@
require 'histogram'
require 'etc'
require 'facter'
+require 'client'
+require 'qps-common'
+require 'server'
require 'src/proto/grpc/testing/services_services'
class WorkerServiceImpl < Grpc::Testing::WorkerService::Service
- def run_server(call)
+ def cpu_cores
+ Facter.value('processors')['count']
end
- def run_client(call)
+ def run_server(reqs)
+ q = EnumeratorQueue.new(self)
+ Thread.new {
+ reqs.each do |req|
+ case req.argtype
+ when "setup"
+ server = BenchmarkServer.new(req.setup)
+ q.push(Grpc::Testing::ServerStatus.new(stats: server.mark(false), port: server.get_port))
+ when "mark"
+ q.push(Grpc::Testing::ServerStatus.new(stats: server.mark(req.mark.reset), cores: cpu_cores))
+ end
+ end
+ q.push(self)
+ }
+ q.each_item
+ end
+ def run_client(reqs)
+ q = EnumeratorQueue.new(self)
+ Thread.new {
+ reqs.each do |req|
+ case req.argtype
+ when "setup"
+ server = BenchmarkClient.new(req.setup)
+ q.push(Grpc::Testing::ClientStatus.new(stats: client.mark(false)))
+ when "mark"
+ q.push(Grpc::Testing::ClientStatus.new(stats: client.mark(req.mark.reset)))
+ end
+ end
+ q.push(self)
+ }
+ q.each_item
end
def core_count(_args, _call)
- Grpc::Testing::CoreResponse.new(cores: Facter.value('processors')['count'])
+ Grpc::Testing::CoreResponse.new(cores: cpu_cores)
end
def quit_worker(_args, _call)
Thread.new {