CS257 Assignment: Profiling

Due Monday, 5/9/05. Submit on paper at class time.

You may work with a partner on this assignment, if you wish.

For this assignment, you will use a Java profiler for Eclipse to analyze an example program. The profiler is installed on along with Eclipse on our lab machines, and I will demonstrate it in class on 5/4.

The program you will profile consists of two classes, Dictionary.java and SpellCorrector.java. From the command line, this program is executed like so:

java SpellCorrector wordFile fileToCorrect

where wordFile consists of an alphabetical list of lower case words, one per line, and fileToCorrect consists of any number of words without punctuation. The words in fileToCorrect will be printed out along with their "corrections." This program is a very primitive spelling corrector, so the likelihood that it will effectively correct spelling errors is small. On the other hand, it is coded sufficiently inefficiently that you should be able to make this bad spelling correction happen quite a bit faster than it does now.

You can use words.txt as your word file, and you can create your own file of words to correct. Note that words.txt is about 80,000 lines long.

What to do

First, set up an Eclipse project to test the spelling corrector. Set the command line arguments to refer to your two data files. Test to make sure it compiles and runs properly.

Next, use the profiler, as demonstrated in class, to prepare a report that addresses the following questions. Brevity and clarity are admirable expository traits, so try to write only as much as you need to write to illuminate the ideas in question.

  1. Use a small fileToCorrect (no more than ten words) and give a detailed summary of of the execution time spent in each method.

  2. Use a large fileToCorrect (at least 1000 words) and give a detailed summary of the execution time spent in each method.

  3. Identify as many inefficiencies as possible in the program, replace the relevant code with more efficient code, and give a detailed report describing how much execution time was saved by each of your modifications.

  4. Discuss how you know that your modified code produces the same results as the original code.

Hand in your report on paper, including a printed copy of your modified source code (I'm happy to read text printed 2-up).

Have fun.