# import the necessary libraries import time import os # create a function to measure performance def performance_measure(): """ This function will measure the performance of the computer and compare it to the last result. """ # get the current system performance start_time = time.time() current_sys_perf = os.system("sar -u 1 1") # get the last system performance last_sys_perf = os.system("sar -u 2 1") # compare the results if current_sys_perf > last_sys_perf: # print out the improvement print("Performance has improved by {}%".format((current_sys_perf/last_sys_perf)*100)) else: # print out the decrease print("Performance has decreased by {}%".format((last_sys_perf/current_sys_perf)*100)) # call the performance_measure() function performance_measure()