Question

Using Python on a Windows machine, write a program that compares the execution time of a...

Using Python on a Windows machine, write a program that compares the execution time of a function call to a system call.

Homework Answers

Answer #1
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...')

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Assignment 3 Write a C/C++ windows system program to move a file to a new location...
Assignment 3 Write a C/C++ windows system program to move a file to a new location using the MoveFile function. Write a C/C++ windows system program to delete a file using the DeleteFile function. Upload a ZIP folder containing your source codes.
Write a Python program using that takes a number as input and then prints if the...
Write a Python program using that takes a number as input and then prints if the number is even or odd. The program should use a function isEven that takes a number as a parameter and returns a logical value true if the number is even, false otherwise.
By using Python code answer the following parts: A) Write a program to ask the user...
By using Python code answer the following parts: A) Write a program to ask the user to input their name and then output the type and length of the input. B) Write a program to output the last 11 letters of 'Introduction to Indiana'. C) Write a program to output the 3rd to the 11th letters of 'Introduction to Indiana'. D) Write a program to ask the user to input a float number and output the rounded value of it...
IN PYTHON: Write a program where the user enters a name. Using the read function, check...
IN PYTHON: Write a program where the user enters a name. Using the read function, check to see if the name is in the text document. If it is, respond back to the user the name is found within the list
Write a program in Python using loop that asks for the names of three runners and...
Write a program in Python using loop that asks for the names of three runners and the time it took each of them to finish a race. The program should display who came in first, second, and third place. Think about how many test cases are needed to verify that your problem works correctly.
Write an LC-3 program (machine code) that compares the two numbers located in x3600 and x3601...
Write an LC-3 program (machine code) that compares the two numbers located in x3600 and x3601 and puts the value 0 in R1 if the two numbers are equal, 1 if the first number is larger than the second number, and -1 if the first number is smaller than the second number.
using python Write a program that displays all of states in the U.S. and display each...
using python Write a program that displays all of states in the U.S. and display each state that begins with the letter A.
IN PYTHON : Write a program that asks the user for a number. Write the number...
IN PYTHON : Write a program that asks the user for a number. Write the number to a file called total.txt. Then ask the user for a second number. Write the new number on line 2 with the total for both numbers next to it separated by a comma. Then ask the user for a third number and do the same. Keep asking for numbers until the person puts in a zero to terminate the program. Close the file. Be...
Write a Python Program to ask the team captain to enter the scores of the top...
Write a Python Program to ask the team captain to enter the scores of the top 4 team members. Using the max function, output the top score. Insert into your HW document a screen shot of your program file and of the output in IDLE when you run the program.
Using Python: Write a program which includes functions to calculate the area, perimeter and diameter of...
Using Python: Write a program which includes functions to calculate the area, perimeter and diameter of a circle. You should have a functions compute_area(), compute_perimeter() and compute_diameter(). In addition, you should have a main() function. Your main function should ask the user for the radius of a circle, then ask the user if they would like to compute the area, the perimeter or the diameter. The user should enter "A" for area, "P" for perimeter and "D" for diameter. Your...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT