Question: the assignment: >Measure the time to write a large file using two different output routine: 1. directly calling the UNIX write system call, and 2.

the assignment:

>Measure the time to write a large file using two different output routine:

1. directly calling the UNIX write system call, and

2. using the standard I/O library routine fwrite.

>For each of the two cases above, you will repeat the experiment, using a write size of 2, 16, 128, 1024 (1K), 8192 (8K), and 65,536 (64K) bytes, in each experiment.

In other words, for the first experiment, your program will first open (create) the file, write to the file 2-byte at a time using the write system call, and then close the file. It will do this 10 times, creating 10 new files, each copy with a different name).

>The program will then repeat this procedure, writing 16-bytes at a time, and so on, up to 64KB at a time.

>The program will then repeat these six cases, but using the fwrite call instead of write.

>The file size that you will create each time will be 128KB.

>Make sure to create the file in the /tmp directory so that you are measuring on the local file system cost and not overhead associated with a file server.

Timing Issues

> measure the elapsed times for each of the 10 test cases. Before the start of your write loop, your program will call the gettimeofday system call; immediately after the loop, it will again call gettimeofday. The difference between these two values is the elapsed time. You will also record the number of write operations (numbers of calls to write or fwrite.

>Note that time kernel call is precise only to a second. This precision is not sufficient for this assignment, so you should use a more precise measure, the gettimeofday call. (There are even more precise measurement methods, such as the rdtsc instruction on a Pentium processor.)

The Experimental Method

>Perform the experiments: Run the program for each of the cases described above, recording the results in a table or another format. Besides time and number of calls, calculate time per write and time per byte.

>Summarize the results. Write a paragraph to summarize what patterns in the results.

>Draw conclusions: Write a paragraph explaining what you can conclude about the results. The goal of the conclusions is to try to explain why the patterns appeared. Why the results for write so different from 2 to 64K bytes? Why do the results for write and fwrite differ? What can you conclude about the way in which fwrite works?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!