GSP 215 Week 4 Homework Optimizing Program Performance

Optimizing Program Performance   A programmer must write correct code that is clear and concise. There are also circumstances in which a programmer must write fast and efficient code. Processing video frames in real time must be fast. We will talk about ways to optimize code. Given the following code, perform these operations to optimize the code. See Chapter 5 in the book for more details on code optimization. Please use comments to document all optimizations you have made to the code. 1. � Using switch instead of if 2. � Eliminating length calls out of the loop test 3. � Put the most used variables first when initializing variables 4. � Use prefix operations rather than postfix operations 5. � Loop unrolling”�increase the number of elements computed in each iteration of a loop (i.e. instead of processing arrays separately, if you have two arrays of the same length, process them in parallel) 6. � Any other improvements you want to make   #include #include #include using namespace std;   #include #include #include using namespace std;   int main() { � �  //This program stores the items purchased at the grocery store. The price vector stores the prices for each item purchased. � �  //The product name vector stores the products purchased and the category vector stores which category the item falls under. � �  //Frozen foods have a 10% discount, snacks has a 5% discount, and produce has a 15% discount. � �  //The total amount of items purchased should be calculated with a 7% tax rate. �  double sum; � �  double tax,totalAmount;   � �  vector price; � �  vector productName; � �  vector category; � �  � �  price.push_back(4.5); � �  price.push_back(10); � �  price.push_back(1.25); � �  price.push_back(2.75); � �  price.push_back(9.50);

Previous answers to this question


This is a preview of an assignment submitted on our website by a student. If you need help with this question or any assignment help, click on the order button below and get started. We guarantee authentic, quality, 100% plagiarism free work or your money back.

order uk best essays Get The Answer
Uncategorized

Leave a Reply

Your email address will not be published. Required fields are marked *