Software tools for structuring complex program, Programming Languages

Assignment Help:

This assignment begins software tools and techniques for structuring complex programs. Use it to become familiar with these facilities, and ensure you use the speci?ed concepts in your assignment solution.

1. Run the following C++ program with and without preprocessor variable POSTFIX de?ned.

#include
using namespace std;
extern "C" int atoi( const char *str );
struct Node {
int i, j, k;
Node() {}
};
int main( int argc, char *argv[ ] ) {
int times = 10000;
switch ( argc ) {
case 2:
times = atoi( argv[1] );
} // switch
vector v( 10000 );
vector::iterator vi;
volatile int j = 0; // ignore, prevent loop elimination
for ( int i = 0; i < times; i += 1 ) {
for ( vi = v.begin(); vi != v.end();
#ifdef POSTFIX
vi ++
#else
++ vi
#endif
) {
j += 1; // ignore, prevent loop elimination
}
}

Compare the two versions of the program with respect to performance by doing the following:

  • Time the execution using the time command:

% time ./a.out

3.21u 0.02s 0:03.32 100.0%

(Output from time differs depending on your shell, but all provide user, system and real time.) Compare the user time (3.21u), which is the CPU time consumed solely by the execution of user code (versus system and real time).

  • Use the program command-line argument (if necessary) to adjust the number of times the experiment is performed to get execution times in the range 0.1 to 100 seconds. (Timing results in the range of .000001 to .01 seconds are inaccurate.) Use the same command-line value for all experiments.
  • Run both the experiments again after recompiling the programs with compiler optimization turned on (i.e., compiler ?ag -O2). Include all 4 timing results to validate your experiments.
  • Explain the relative differences in the timing results with respect to pre?x and post?x increment of a vector iterator.
  • Does compiler optimization affect either version? (Yes/No answer)
  • Give at least one URL from the web that disagrees with your conclusion

Related Discussions:- Software tools for structuring complex program

Built a liner program to manage a staff, A manager at the local Walmart nee...

A manager at the local Walmart needs to determine how many workers to hire to cover a 24-hour period. Each worker must work 9 consecutive hours but may only start work at the begin

Define the procedures cons, Show that we can represent pairs of nonnegative...

Show that we can represent pairs of nonnegative integers using only numbers and arithmetic operations if we represent the pair a and b as the integer that is the product 2 a 3 b .

Assembly language, I need help with having a user input a year, and my prog...

I need help with having a user input a year, and my program to spit out what day of the week Christmas is on.... any helping hands on this?

Write a program to read a text file and create a dictionary, Write a progra...

Write a program to read a text file and create a dictionary. The keys for the dictionary should be all 26 letters of the alphabet and the values of the dictionary should be the lis

Develop html code create web page of blue color , 1.  Develop an HTML code ...

1.  Develop an HTML code to create a Web page of blue color & display links in red color. 2.  Develop an HTML code to create a Web page which contains an image at its center.

Describe url and hostname part, Describe URL and hostname part? The hos...

Describe URL and hostname part? The hostname part of the URL should be a valid Internet hostname. It can also be an IP address like as 204.29.207.217 or 128.235.252.184. The

Mathematical expression of linear programming problem, A Consultant Dietici...

A Consultant Dietician provides diet and nutritional advice to clients. A client's diet requires that all the food s/he eats come from one of the four "basic food groups" (chocolat

Program for hold details of all the cabins for travellers, Scenario A ca...

Scenario A campsite provides cabins for travellers to stay in overnight. A 'cabin' is a small wooden hut, containing bunk beds, table and chairs, a heater, and a small cookin

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd