nats-io / nats.rs

Rust client for NATS, the cloud native messaging system.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Average processing time calculated incorrectly

jadamcrain opened this issue · comments

Observed behavior

It always divides by 2, but it should divide by the number of requests served:

stats.average_processing_time = stats.processing_time.checked_div(2).unwrap();

I believe this should be:

stats.average_processing_time = stats.processing_time.checked_div(stats.requests).unwrap();

Expected behavior

The avg time should total time / # requests

Server and client version

current tip of main

Host environment

No response

Steps to reproduce

No response

If the endpoint returns total requests and total time it seems like the CLI should calculate the average?

Then every language implementation wouldn't have to do it since it's a "derived quantity" for the underlying data.

oh, that is a silly mistake.
Will issue a fix shortly, unless you want to contribute it 🙂

I'll do it just to get a PR, why not.

Fixed in #1152

Thank you @jadamcrain !