CSc265 -- Exercise 4

DUE: midnight, Thursday 21 November 1996


Overview

This is an exercise in using the tcov tool to see where statements inside a program are heavily executed. The file encode.c contains the source code for a program named encode which computes the VCR+ code for a specified TV program. VCR+ codes are shown, for example, in the TV listings section of the Victoria Times-Colonist. They provide a rapid way to enter data into a VCR.

Your task is to make the encode program execute more efficiently.

Preparing for the Assignment

The directory /home/csc265/Exercises/Ex4 contains two files, named encode.c, and testdata You should copy both files into your own directory.

You should compile the encode.c to create the program named encode. You can run encode interactively by just entering the command

	encode
and then entering the requested information, namely the date of the TV program, the channel, the starting time, and the program duration.

You can also run encode interactively by supplying a filename argument, where the file contains the information about each TV program for which the VCR+ number is desired. The file testdata is an example of such a file.

This version of encode is restricted to programs which begin on the hour or on the half hour, and have a duration which is a multiple of 30 minutes, up to a 5 hour maximum. More information about program usage is provided in the comments at the start of the encode.c file.

The Desired Task

Following the instructions supplied in the course notes, run encode so that execution count information can be obtained with the tcov command.

By inspecting the output produced by tcov, you should locate places in the encode program where you can significantly speed up program operation. Use the testdata file (or an even larger file) as input so that you exercise the program as much as possible.

You are to select one function in the program where a recoding of the function's logic would have the most effect. You should re-code that function, verify that the new version of the program is more efficient, and then submit the source code for your revised program.

Submitting Your Solutions

Make sure that the names of your team members and the lab section which you attend appears in the comment at the beginning of the encode.c file. Then submit your improved encode.c program to the csc265 using a command like the following:
	% mail -s 'Exercise 4 submission' csc265@gulf < encode.c


Grading Criteria

You will receive the maximum score for

As always, you may submit the assignment only once because only the first submission will be graded.