GSP 215 Week 4 iLab Optimizing Program Performance latest
Week 4 Lab Optimizing Program Performance
TCO 4—Given the importance of speculating runtime costs of software, obtain an understanding of certain details of how processors operate that impact code performance.
In this week’s lab, you will look at timing operations and how different operations can take a different amount of time to complete.
We will look at timing operations in C++. To see the difference in operations, write C++ code to compare cout and printf, and display the time difference for 100 cout operations and 100 printf operations. This code can be written in Visual Studio. Below is how you would time the 100 cout operations in Visual Studio. Add another for loop, and display time for both cout and printf then comment about why you think there is a difference.
Next, we will take timing a step further. There are a few different sorting algorithms, and these algorithms have varying time complexity. For this part of the lab, we will implement bubble sort and quick sort. Research bubble sort and quick sort algorithms, and implement them in C++. Fill a large array (maybe 15,000 elements) of random numbers. Then time the difference between bubble sort and quick sort 10 times, and fill out the table. Next, run the program in release mode. Did you notice a difference in time? Yes, release mode works much faster