Little's Law connects three average quantities in a stable system:
Design a LittlesLawCalculator class:
LittlesLawCalculator() creates a stateless calculator.double solve(double throughput, double concurrency, double latencySeconds) returns the missing quantity, rounded to 5 decimal places.
Exactly one argument is -1:
throughput is completed requests per second.concurrency is the average number of requests in the system.latencySeconds is the average time one request spends in the system, measured in seconds.
The other two arguments are positive. Detect the -1 argument, rearrange Little's Law, and round only the final result. Every call is independent.
Example 1:
Input:
Output:
Explanation: The service completes 100 requests per second and each request spends 0.05 seconds inside it, so average concurrency is 100 × 0.05 = 5.
Example 2:
Input:
Output:
Explanation: With 5 requests in flight and 0.05-second latency, throughput is 5 / 0.05 = 100 requests per second.
Constraints
- Exactly one argument equals
-1. - Each known argument is between
10^-5 and 10^4, inclusive. latencySeconds is expressed in seconds whenever it is known.- The system is stable, so its long-run arrival and completion rates match.
- Round the final answer to 5 decimal places.
- Answers are accepted within
10^-5 of the expected result. - At most
100 calls are made to solve.