Practice ยท 3 of 3
Iteration Budget Math
CHALLENGE
Difficulty: advanced+25 XP
ISO C. Implement size_t iters_for_budget(double budget_ms, double per_iter_ms) โ return the number of whole iterations that fit the budget, rounding up (a partially affordable iteration still runs once); return 0 when either argument is <= 0. Implement double bench_sink(size_t iters) that accumulates a workload into a local volatile double sink (sink += (double)i / 4.0 each iteration) and returns the sink โ proving the work was not optimized away.
Press Submit to check your solution.
Back to lesson: Practice: Layout and Measurement Drills