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
Abstraction hierarchy of mechanisms Given  the light-sensitive the motor and resistor,  we could  find  several  ways  of interconnecting them, using bits of ceramic and metal

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

What is DOM? The Document Object Model is a platform- and language-neutral interface that will allow programs and scripts to dynamically access and update the content, structure an

develop a pseudocode algorithm to determine the total amount of extra cost changed to the organizers for expenses accurednduring the workshop. the code is to be written for an unde

Assignment is to create hijara game on any plate form, you can use any plate form you like or easy to you. For instance let's say you can use visual studio, game studio (Prefer to

Question: (a) Explain the concepts of Inheritance and Polymorphism in Lingo programming. (b) Write short descriptions on parent scripts and child objects in Lingo object

Object-oriented programming paradigm Object  Oriented  Programming  is  an  aproach  in  which  a  program  is  viewed  as  a  dynamic  network  of collaborating objects, where

Write a Prolog predicate remove_nth(N,L1,L2) that is true if list L2 is just list L1 with its Nth element removed. If L1 does not have an Nth element then the predicate should fail

Project2: A Simple Distributed Computing Platform (Due at 11:59:59pm on 04/12/2012 (EST)) Description: You are asked to develop a replicator (client) that distributes a large job

I need an application that will gather data from one SQL Database and update another. Data is contained in dbo.CallList with following fields: Customer_ID, AlreadyPickedUp, Phone_N