Measure the hardware performance for executing a particular line of code

Viewed 43

In Python, I would like to know the hardware performance for executing a particular line of code. What's your preferred way of getting the hardware performance such as CPU load and memory usage?

1 Answers

https://pypi.org/project/psutil/ is the library that you want

psutil (process and system utilities) is a cross-platform library for retrieving information on running processes and system utilization (CPU, memory, disks, network, sensors) in Python. It is useful mainly for system monitoring, profiling and limiting process resources and management of running processes. It implements many functionalities offered by classic UNIX command line tools such as ps, top, iotop, lsof, netstat, ifconfig, free and others. psutil currently supports the following platforms:

Related