-
Book Overview & Buying
-
Table Of Contents
Supercharged Coding with GenAI
By :
Profiling runtime and memory usage is a straightforward process. The built-in time module is useful for tracking runtime and the third-party memory_profiler library monitors memory usage. The next two sub-sections describe how GitHub Copilot can assist by either completing our implementation or generating the code from scratch for these two cases. At the end of this section, we will ask ChatGPT to predict runtimes and memory size constraints using these analyses as input.
Measuring the runtime of a function in Python helps evaluate whether the time taken to complete the tasks in the source code aligns with acceptable thresholds and identifies potential areas for improvement. This can be achieved using a script like the following:
start = time.process_time()
recursive_fibonacci(35)
end = time.process_time()
print(f"Time taken: {end – start:.3f} seconds")
By recording the...