Using Python on a Windows machine, write a program that compares the execution time of a function call to a system call.
import os import time import subprocess def fun1(): print('Write a program to compare execution time\n') print('Function 1\n') def fun2(): subprocess.call(["dir"], shell=True) start_time = time.time() fun1() end_time = time.time() print('Time taken by python function') print(end_time-start_time) start_time = time.time() fun2() end_time = time.time() print('Time taken by system call') print(end_time-start_time) print('Exiting application...')
Get Answers For Free
Most questions answered within 1 hours.