Code for Measuring Throughput and Latency Distribution

I am beginner in Go. Also Go is my first programming language. I am learning the course via Udemy.
I am trying to set up a load test for a gRPC service in my project. I am not unable to figure out the code/syntax I need to:

  • measure the throughput in requests/seconds
  • also measure the latency distribution using configurable bin sizes (e.g. 1ms)
  • from the distribution histogram, derive a 90% and 99% percentile, this only needs to be accurate to the bin size, but should be conservative, so rounded up.

Here’s the part of my code:

		start := time.Now() // Capturing the start time
		r, err := c.GetItem(ctx, &pb.GetItemRequest{Id: "NAME"}) // Making a gRPC request
		elapsed := time.Since(start) // Capturing the latency
	if err != nil {
			return fmt.Errorf("Couldn't fetch a response :%r", err)
		} else {
			log.Printf("Response: %s", r)
			log.Printf("GetItem took %s", elapsed)
		}
	}

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.