Homework # 1 (corrected 9/13)
due 9/14/03

(This homework, as in all homeworks, must be completed by each person separately. You may discuss the problems with each other and help each other, as long as you write the names of the people you worked with prominently on your homework. You may not use xerographic or electronic copying; please do not send help in the form of emailed or xeroxed answers.)

Measuring a Scanner

Using the file big.cl (a very large COOL program), determine the following measurements:

  1. What percentage of the compilation is taken up by the scanner? Compare the time to run coolc with the time to run lextest, without output. You should use several runs to get a good sense of the proportion.
  2. Of the scanner time, what proportion of the time is spent using the string table and what time for the rest of the scanner? (Compile lextest with a stubbed-out string table abstraction to avoid all work with token tables, and see how much faster it runs.) Now you can compute the fraction of time spent in scanning proper. This is the amount of time that could conceivably be reduced by a better scanner implementation.
  3. flex has a lot of flags that control how the scanner engine is built. Find the combination that gives the best reduction in scanner time. Give the percentage reduction in time. (100% means the optimized scanner is instantaneous, an unachievable goal.)
For all these measurements, show your work.

Modify lextest so that you can

The modified file lexcount.cc should be left in your homework1 directory. Please also report what the results are using file big.cl.

Files

Most of the Cool2004 compiler source is available in $CLASSHOME/src/coolc. You will not be able to simply compile the code. You will need to select individual files. Part of this assignment is getting you familiar with some of the pieces of the Cool compiler.

Example Cool files (including big.cl) are available in $CLASSHOME/examples/.

Deliverables

You should turn in a hard-copy report showing your results and also leave the relevant modified code in the homework1 directory. This directory may also include all your work.



John Tang Boyland
2004-09-13