Skip to content
DeepForgeby svx
All problems
MediumDeep Learningdl-305

Batch-Latency Tradeoff

Problem

Given measured latency per batch size, compute throughput = batch / latency * 1000 (items per second) and return [best_batch, best_throughput] for the batch with the highest throughput, breaking ties toward the smaller batch.

The signature is batch_latency_tradeoff(batch_sizes, latencies).

Hint

Throughput usually saturates while latency keeps growing with batch size.

Test cases

case 1
in: [[1,4,16],[10,20,100]]
expected: [4,200]
case 2
in: [[1,2],[5,5]]
expected: [2,400]
case 3
in: [[1],[2]]
expected: [1,500]
case 4
in: [[8,16],[40,120]]
expected: [8,200]
Starter codePython
def batch_latency_tradeoff(batch_sizes, latencies):
    # Your code here
    pass

4 test cases · run your code against them in the editor