All problems
Batched Throughput
Problem
Compute batching throughput. The number of batches is ceil(n_requests / batch_size), total time is batches * latency_ms, and throughput is n_requests per second. Return [batches, total_time_ms, throughput]; non-positive arguments return [0, 0.0, 0.0].
Hint
Larger batches raise throughput but add queueing delay for the first requests.
Test cases
case 1
in: [100,32,50]
expected: [4,200,500]
case 2
in: [10,10,100]
expected: [1,100,100]
case 3
in: [7,3,30]
expected: [3,90,77.77777777777779]
case 4
in: [0,5,10]
expected: [0,0,0]
Starter codePython
import math
def batched_throughput(n_requests, batch_size, latency_ms):
# Returns [batches, total_time_ms, throughput]
# Your code here
pass4 test cases · run your code against them in the editor