#C12867. Function Monitoring and Logging
Function Monitoring and Logging
Function Monitoring and Logging
This problem requires you to implement a function monitoring system using decorators. You are provided with two functions: example_function
and another_function
. Your task is to instrument these functions so that every call is recorded with its execution time and the total number of invocations. In addition, each call should be logged using a standard logging mechanism.
The example_function
simulates a processing time of 1 second and returns the sum of its two integer arguments. The another_function
simulates a processing time of 2 seconds and returns the square of its integer argument.
Your program will read a series of commands from standard input. Each command directs a call to one of these functions along with its parameters. After processing all the commands, you must output two lines: the first line for example_function
and the second for another_function
. Each line should report the total call count and the accumulated execution time (rounded to two decimal places).
inputFormat
The first line of input contains an integer n representing the number of function calls. Each of the following n lines describes a function call in one of the following formats:
• example_function x y
- x and y are integers to be passed as arguments to example_function.
• another_function a
- a is an integer to be passed as an argument to another_function.
outputFormat
The output consists of exactly two lines:
• The first line reports statistics for example_function in the following format:
example_function call_count total_time
• The second line reports statistics for another_function in the following format:
another_function call_count total_time
Here, call_count is the number of times the function was called and total_time is the total execution time accumulated by that function, rounded to two decimal places.## sample
1
example_function 1 2
example_function 1 1.00
another_function 0 0.00
</p>