Homework 7
Document last modified:
Overview
The text presents algorithms and analysis of an Insertion and Quick sort. The assignment seeks to verify empirically the accuracy of those analysis's by profiling the execution of each algorithm under specific conditions.
Profiling program execution provides detailed empirical data on algorithm performance at different levels of granularity and measures.
The assignment uses a profiling system to acquire runtimes of the two sorting algorithms under varying problem sizes and initial orderings (sorted or random).
Purpose of Assignment
Assignment Software
If you cannot get a profiler to work (e.g. Visual Studio) use the elapsed times printed by program execution, though these times are not as accurate as a profiler. Using the printed times, for data sorted in ascending order, all times will likely be 0.0000 because the clock interval is too large to measure the execution times. In that case you will not be able to analyze ascending data in the following questions but should get sufficiently accurate results for random and descending data.
1. MicroProfiler installation
Integrates with Visual Studio, simple to use and works. You should be able to install on IUS computers without administrative rights. Homepage at: http://code.google.com/p/micro-profiler/
Install Visual Studio, any version should work but has only been tested with 2008. Available at: Visual Studio 2008
Download latest MicroProfiler Deployment Package and unzip.
Follow installation and use instructions at: http://code.google.com/p/micro-profiler/wiki/UsageGuidelinesAutomatic
Remove the extraneous ; on the end of line 3: Perform the registration: regsvr32 micro-profiler.dll;
Visual Studio Project
- Copy the two files: driver.cpp, QuickSort.h and InsertionSort.h
- Follow instructions to build a project: How to Create a Visual Studio Project
Watch this screen capture repeatedly until you get all the details.
- Project - Increase stack size for deep recursion.
- Open the Solution Explorer | Click on the project name, then
- Project | Properties | Configuration Properties | Linker | System | Stack Reserve Size | 100000000
2. Visual Studio 2008 installation
Copy the two DVD's in LF111A in the drawer marked C455 DVD's
or download
and install in the following order:
|
Profiling using Visual Studio
- After creating the project, run one time the Performance Wizard
- Here's how to Make a Profile Run using the Performance Analyzer
Assignment
In driver.cpp, comment
out the #include to select between Insertion and Quick sorts.
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
| Sorting Algorithm |
Random, Ascending or Descending |
# Items Sorted |
Number of Calls | Elapsed Exclusive Time |
Elapsed Inclusive Time |
Time Spent per item |
Math Function |
Ratio Col #6/#8 |
- Time spent per item.
- Math functions constructed by you that takes the number of items sorted as its only parameter and produces as a result an approximation to the "Elapsed Inclusive Time" spent in the operation. These functions should correspond to the behavior elicited by the different data orderings. The Excel math function, where cell C11 contains the number of items sorted, could be similar to: =0.123*C11*C11. Note that exactly the same function should be used for each group of five sets, 7500 to 120000.
- The ratio of the recorded "Elapsed Inclusive Time" to result of the math function. Repeatedly rework the function in 2. above in an attempt to drive the ratio to 1.0, meaning they agree. Note that, due to variations in inclusive execution times of the five sets, the ratio will not be exactly 1.0; 0.95 to 1.05 is certainly acceptable.
Analysis of results
- the 3 Insertion sort results.
- the 3 Quick sort results.
- Insertion and Quick sort on descending data results.
- Insertion and Quick sort on random data results.
- Insertion and Quick sort on ascending data results.
- x axis = size of the data (Column #3)
- y axis = total time spent (Column #6)
Note: a significant portion of the grade for this project depends on what you write in response to these questions.
What to Turn In: