This exercise is designed to reinforce the concepts discussed in the lectures. There are no marks for completing this exercise, however your attendance at tutorials and successful completion is officially recorded and may be used as a positive adjunct to assessment in special circumstances.
You are strongly advised to compete the exercise as it will help you with the concepts discussed in lectures and assist you in successfully completing the practical work. Exercises often mysteriously reappear as exam questions.
Topic: Use metrics and profiles to analyse and improve
the Rational class.
Purpose: a chance to gain experience with code analysis and optimisations.
Background: Download
the solution to the previous exercise — the Rational
class. Note that the solution includes a new Tester
class, which
will be used to generate data for the profiler to profile.
You are required to use object-oriented metrics and a profiler
to optimise and test correctness for the Rational
class.
How to Proceed:
Rational
class provide the following metrics: gprof
, to profile the program and
find out which methods most of the CPU time is spent when the Tester
class is active.Rational
class
(no other classes need to be optimised). Re-run your profile and calculate
the percentage speed improvement. Hints: