V22.0201 (sec. 1) - Computer Systems Organization (Honors)

Assignment 5A - Analyzing Code Performance

In view of the difficulties implementing the music program on Windows 2000 or XP, we are providing an alternative assignment for Assignment #5.  You may do either the original Assignment 5 (the music program) or this Assignment 5A.

This assignment asks you to pit your programming skills against that of the Visual C++ compiler on two small applications, the List functions (Assignment 4) and the string utilities (from the C textbook).

Code the head, tail, and member functions form Assignment 4 in assembler;  name them ahead, atail, and amember.  (You may want to consult p. 135-138 of Carter's notes regarding structures.)  Compare the speed of

(Note:  the optimization level of the Visual C/C++ compiler is selected under Project ... Settings ... C/C++ tab ... Optimizations pull-down menu.  You must also remove the /ZI and /GZ options under "Project Options" at the bottom of that tabbed pane.  The speed of the program can be determined using clock();  doing
  start = clock();
 blahblahblah;
 finish = clock();
 duration = (double)(finish - start) / CLOCKS_PER_SEC;
puts in duration the time required for blahblahblah.)

Tabulate, as accurately as you can, the time required (in nanoseconds) for a call to head/ahead, for a call to tail/atail, and for a call to member/amember.  For member/amember, the time should be stated as a function of the length of the list.  It is recommended that you run the program several times to make sure you are getting (roughly) consistent times;  you may find the times for the first run somewhat different from later runs.

Perform the same analysis for the string functions strcpy,strcmp, and strchr.  Compare

You might want to look at Carter's section on array/string operations (section 5.2, p. 99) for ideas on writing string code, although the examples given there may not be optimal in terms of Pentium III speed.  For all the string functions, the time should be stated as a function of the length of the string.

This assignment is due on November 26th and is worth 15 points.  If, for at least one function, you beat the speed of the optimized C compiler by at least 10% with your assembly code, you get one more point.  As usual, there is a penalty of 1/2 point for each day late.

Email your assignment to the grader.  This includes all your code and a 1-2 page write-up (in Word format) describing your results. Show the raw data you obtained and the computed times. Please include the type and speed of the CPU you are running.  Include your name and "Asgn 5" in the subject line.