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

Python, Write a python script that will take two file names as input (src, ...

Write a python script that will take two file names as input (src, dest). Open src reading each line in the file, and replacing any occurrences of name with the string "redacted".

Er diagram, I need someone to make an ER diagram.

I need someone to make an ER diagram.

Python , Python Programming hmw help!! Write a program that ask the user to...

Python Programming hmw help!! Write a program that ask the user to input the followings: number of shares, stock price, and broker commission. Last month jim purchased some stock

Characteristics of procedure-oriented programming, Characteristics of proce...

Characteristics of procedure-oriented programming: Emphasis is on doing things (algorithms). Large programs are divided into smaller programs known as functions.

Software engineering, Assigment 01 Subject Code: ITE 2106 Subject Name: Sof...

Assigment 01 Subject Code: ITE 2106 Subject Name: Software Engineering You run a software development organization catering to external clients to build software solutions. The bus

Write a program to display some data in bar graph form, Write a program to ...

Write a program to display some data in bar graph form. Have at least 20 elements, which can be positive or negative; draw each element with a vertical bar, going up if the data is

Java.., create a program that can determine the number of students that are...

create a program that can determine the number of students that are doing their final year for a particular program (e.g. BCOM Information Systems), calculate the required credits

Python , Write a script that will list and count all of the images in a giv...

Write a script that will list and count all of the images in a given HTML web page. Each image starts with

Create application for a book store, You need to create a simple applicatio...

You need to create a simple application for the Note Plus book Store. The interface for the application is shown below:   REQUIRED: 1)  Create all necessary contro

Return value in an array, A specification of a function TOARR is given belo...

A specification of a function TOARR is given below. function TOARR(n in Int, s in Stack of Int) return in Array of Int pre n ≥ 0. post The returned value is an array of size

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