Listing 1: Timing execution of an entire program

#include <iostream.h>
#include <string.h>
#include <ctype.h>
#include "chrono.h"

//allow long input lines
#define MAXLINE 1024
 
void getcmt(istream &in);
void usage(void);

// Global program name, for messages.
char *pgm = "GETCMT";
 
// -----------------------------------------
main(int argc, char *argv[])
{
   int    i;
   double elapsed_time;
   // This Chronograph measures total
   // elapsed time of program.  It starts
   // running as soon as it's instantiated.
   Chronograph chrono;

   // --------------------------------------
   // Command line processing, details
   // omitted
   // ...

   // --------------------------------------
   getcmt(cin);
   elapsed_time = chrono.elapsed();

   // Show the total time this program was
   // running.
   cout << endl;
   cout << pgm << " main()";
   cout << ": Total elapsed time: ";
   cout.precision(2);
   cout <<  elapsed_time;
   cout << " seconds." << endl;
   cout << endl;

   return 0;
}
//End of File