Homeowrk 6, Process Time

Short Description:

Compute the runtime of a program.

This assignment is worth 50 points.

Goals

When you finish this homework, you should:

Formal Description

The clock cycle of your computer is one of the factors which determines how much time a program will take to run. You are to write a program which given the speed of the processor and the number of instructions a program executes, will compute how much time that program will take to finish. We will make a simplifying assumption that your computer can execute one instruction every clock cycle. To determine the run time for your program, you simply need to multiply the length of a clock cycle by the number of instructions your program requires to execute.

For example, if your program requires 2× 107 instructions and your clock cycle is 570ps (picoseconds), the time required is 2× 107 × 570ps = 1.14 × 1010 ps.

Unfortunately, as humans we really don't understand picoseconds. We are more comfortable with things in larger units. Therefor you should convert the time to several more palatable units. To be specific, the program should output the following:

Your program should prompt the user for the clock speed $c$ in picoseconds and the number of instruction $i$. Each of these values will be an integer but may be fairly large.

Example Run, input is bold

Enter clock speed: 570
Enter the number of instructions: 20000000
11400000000 ps
11400000 ns, 0 ps
11400 us, 0 ns, 0 ps
11 ms, 400 us, 0 ns, 0 ps
0 s, 11 ms, 400 us, 0 ns, 0 ps
0 min, 0 s, 11 ms, 400 us, 0 ns, 0 ps

Discussion

If you do not understand the mathematics, or the measurement system seek assistance early.

You should perform all computations as a long to avoid overflow. All data should be stored in an integer type.

All computations can be done with the instructions you know. You do not need if statements or loops to complete this program.

Integer division and modulus are very helpful in this program.

Your identifiers should be constructed properly, with meaningful names.

You should document your code with comments.

Your output should be organized, easy to read, and make appropriate use of white space.

Any numbers with a fixed meaning should be stored as a named constant.

You should only perform any given computation once, store the results. A single source code file.

Submission

Email your final source code file to dbennett@edinboro.edu.