Software tools for structuring complex program, Programming Languages

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
Posted Date: 2/21/2013 6:02:31 AM | Location : United States







Related Discussions:- Software tools for structuring complex program, Assignment Help, Ask Question on Software tools for structuring complex program, Get Answer, Expert's Help, Software tools for structuring complex program Discussions

Write discussion on Software tools for structuring complex program
Your posts are moderated
Related Questions
Your task will be to code a simulation of image compression based on the approximate low rank structure of the set of image patches. You will write functions .code = my block compr

.NET class libraries in .NET Whether you create value in C# or VB.NET, you are getting in touch with techniques in the same .NET category your local library. The same .NET str

On-line fair and ethical share trading system (Olfest) A system is required that allows on-line customers to buy and sell stock market shares in a selection of companies. B

A psychologist is interested in learning about the voting behavior of college students.  (4 points for each part.)Design a study which would yield data on this topic. a. state y

i have a=[0 1 1 2 2 3 6 7 0 4 ] i want to delent elemet but keep its position i.e a(4)=[] it gives me 0 1 1 2 3 6 7 0 4 but i need 0 1 1 [] 2 3 6 7 0 4

1.  Develop a page to indicate distinct attributes of Font tag. 2.  Develop a page to indicate different attributes: bold, italics, underline. 3.  Design a page with backgrou

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

Write a function called triple (in a file called 'triple.m'). That takes a single variable x and returns a single variable in which every element of x is multiplied by 3. Make sure

explain steps of program execution in language processors

We need Advancement in Existing PhoneGap Application We need a PhoneGap expert to aid us extend an existing PhoneGap application. The app works pulls data from a new website (de