Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Time a function's execution

Python data engineering interview problem. Difficulty: beginner. Pattern: OOP. About 10 minutes. Part of the Pro drill bank.

A job wrapper should record that a function ran (and optionally how long) so a log line exists even when the function itself prints nothing useful.

Call a function with logging around it as the tests specify.

Requirements

  • The wrapped function still runs.
  • The log output or return pair matches the tests.

Constraints

  • name and args describe the wrapped call.
  • Do not swallow exceptions unless tests say so.

Examples

Input: call_with_log('sum', [1, 2, 3]) Output: {'name': 'sum', 'args': [1, 2, 3], 'result': 6} This input follows the stated rules and produces this output.

Topics: lakebench, python, decorators.

More Python interview questions · All interview problems · Learn data engineering

beginner

Time a function's execution

Interview-style drill: Write a decorator that measures and reports how long a wrapped function takes to run.

Call a function with logging around it as the tests specify.