AnswerBun.com

grpc python measure response time

Stack Overflow Asked by user3599803 on December 20, 2020

How can I measure the full time grpc-python takes to handle a request?
So far the best I can do is:

def Run(self, request, context):
   start = time.time()
   # service code...
   end = time.time()
   return myservice_stub.Response()

But this doesn’t measure how much time grpc takes to serialize the request, response, to transfer it over the network.. and so on. I’m looking for a way to "hook" into these steps.

One Answer

You can measure on the client side:

start = time.time()
response = stub.Run(request)
total_end_to_end = time.time() - start

Then you can get the total overhead (serialization, transfer) by reducing the computation of the Run method.

To automate the process, you can add (at least for the sake of the test) the computation time as a field to the myservice_stub.Response.

Answered by Mark Loyman on December 20, 2020

Add your own answers!

Related Questions

Detect if Class has an element inside of certain Class?

1  Asked on November 17, 2021 by ohval

 

Syntax error: missing ‘;’ before ‘*’ with Item class

1  Asked on November 17, 2021 by theandrewjeff

   

Run a query based on the values returned by another query

3  Asked on November 17, 2021 by kevin-d

 

simplfied observer pattern with std::shared_ptr/weak_ptr

1  Asked on November 17, 2021 by fatun

   

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP