Project 1b

Due Date: Sun 18 Sep (firm!)


  • Familiarity with test-driven development.
  • Familiarity with performance considerations.
  • Refresher of associative data structures.


  • Develop a comprehensive unit test fixture for the properties and methods of the IDictionary interface (not including the extension methods).
  • Using suitable reuse and parameterization techniques, create specialized test fixtures for these implementation classes:
    • Dictionary
    • SortedDictionary
  • Develop a performance evaluation test fixture for the IDictionary interface along the lines of the list-performance-csharp example from the course repository. Focus on the methods Add(TKey, TValue), ContainsKey(TKey), and Remove(TKey).
  • Apply the performance evaluation to both above-mentioned dictionary implementations.
  • Be sure to measure the running times in for the various above-mentioned methods in isolation. For example, you first have to populate the dictionary instance (using, say, Add) before you can evaluate the performance of ContainsKey. This means you cannot simply rely on the running times of each test method. Instead, use the Stopwatch class for measuring the running times of specific sections of a test method; here is a little tutorial, but be sure to refer to the most recent API doc (preceding link) or your IDE's code assist. 
  • Save the output indicating the test times to a file.
  • Interpret your findings and include your answers to the following questions in a write-up of about 300 words:
    • Which of the two dictionary implementations performs better as the number of entries increases?
    • Is one type of dictionary always better than the other, or does the performance depend on the specific operation we perform?


  • 7 correctness test
    •   0.5 points for each of 5 IDictionary properties
    •   0.5 points for each of 9 IDictionary methods (i.e., not counting GetEnumerator)
  • 2 performance test Dictionary
    •   0.5 Add
    •   0.5 Remove
    •   1 ContainsKey (in isolation, for globally fixed number of reps, should grow with # items)
  • 2 performance test SortedDictionary
    •   0.5 Add
    •   0.5 Remove
    •   1 ContainsKey (in isolation, for globally fixed number of reps, should grow with # items but more than Dictionary)
  • 1.5 using suitable reuse and parameterization techniques to avoid code duplication
    •   (typically use aux methods invoked by the various test methods)
  • 2.5 written part
    •   0.5 describe results - Dict better than SortedDict
    •   0.5 discover Dict const, SortedDict log
    •   0.5 Dict usually faster
    •   1 interpret results e.g. Dict hash, SortedDict tree


Please follow these instructions.