I am writing code to count CPU time for a program. The related code is like this:
with open(script_path, "r") as src:
scr_contents = src.read()
proc = subprocess.run(["python", script_path], capture_output = True)
cup_time = time.process_time()
This script gives me the CPU time for running the whole program of scr_contents.
Now, suppose I have many snippets in this program and I want to get the CPU time for each snippets, what method or function available for this purpose of CPU time counting?