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

Perform dbscan clustering and k means, Perform Dbscan Clustering and K mean...

Perform Dbscan Clustering and K means I have a simple array of data. I need to perform dbscan clustering and k means based on the values in the array.detailed description  bel

Maximization, A company produces three sizes of window fans small, medium a...

A company produces three sizes of window fans small, medium and large. the manager has formulated an LP model for fan production Maximize 6x1+8x2+5x3

Shell script print “gm/afternoon/evening”acc to system time, Normal 0 ...

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

Write an application to assign seats for each flight, ( Airline Reservation...

( Airline Reservations System ) A small airline has just purchased a computer for its new automated reservations system. You have been asked to develop the new system. You are to w

Non empty string - minimal unique substring, A non-empty string is called a...

A non-empty string is called a minimal unique substring of s if and only if it satisfies: (i) α occurs exactly once in s (uniqueness), (ii) all proper prefixes of occur at le

Find the dual - duality theory and complementary slackness, Linear Programm...

Linear Programming Consider the following optimization problem: min x s.t. x ≥ max{a1, a2, . . . , an} Rewrite this problem as a Linear Programming Problem. What is the

Write a function to draw backbone of the protein, Write a function drawCA(a...

Write a function drawCA(aname, coords) that uses the plot3 command to draw the C α backbone of the protein. When calling this function, you should pass in the aname and coords var

Differentiate between high level and low level languages, The languages use...

The languages used in the module are of a type known as high-level languages. There is another set of languages known as low-level languages. (a) Differentiate between high-leve

What is cisc & risc?, Question 1 What is CISC & RISC? Explain their addres...

Question 1 What is CISC & RISC? Explain their addressing modes Question 2 Discuss the following- Design Specification of Assembler Design of Single Pass Assembler

Shell script to print the name of file that has maximum size, Normal 0 ...

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

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