Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/Go4ProfileTimer/MainProfileTimer.cxx

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 #include <unistd.h>
00017 #include <iostream.h>
00018 
00019 #include "TGo4ProfileTimer.h"
00020 #include "TApplication.h"
00021 
00022 void usage();
00023 
00024 //______________________________________________________________________________
00025 int main(int argc, char **argv)
00026 {
00027   TApplication theApp("App", &argc, argv);
00028 
00029   int rc ;
00030 
00031   if(argc == 1)
00032     usage();
00033 
00034   TGo4ProfileTimer *tim = new TGo4ProfileTimer();
00035   TGo4ProfileTimer::TGo4ElapsedTime et;
00036   TGo4ProfileTimer::Rusage ru;
00037 
00038   rc = tim->Start();
00039 
00040   int nint = atoi(argv[1]);
00041   for(int i=0;i<nint;i++)
00042     {
00043       if(argc > 2)
00044    {
00045      if(!strcmp(argv[2],"sleep"))
00046        sleep(1);
00047      else
00048        ;
00049    }
00050       else
00051    ;
00052     }
00053 
00054   rc = tim->Stop();
00055 
00056   rc = tim->ElapsedTime(et);
00057   tim->ElapsedRusage(ru);
00058 
00059   cout << "\nTiming\n";
00060   cout << et.fdRealTime << endl;
00061   cout << et.fdUserTime << endl;
00062   cout << et.fdSystemTime << endl;
00063   cout << "\nRusage\n";
00064   cout << (float)(ru.ru_utime.tv_sec + (float)ru.ru_utime.tv_usec/1000000.)  << endl;
00065   cout << (float)(ru.ru_stime.tv_sec + (float)ru.ru_stime.tv_usec/1000000.)   << endl;
00066   cout << "\nRusage: Context switch\n";
00067   cout << ru.ru_nvcsw << endl;
00068   cout << ru.ru_nivcsw << endl;
00069 
00070   tim->Resume();
00071   tim->Memory();
00072 
00073   //theApp.Run(kTRUE);
00074 
00075   return 0;
00076 }
00077 
00078 void usage()
00079 {
00080   cout << "Usage: ProfileTimer #number sleep\n";
00081   exit(1);
00082 }
00083 
00084 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:56:04 2005 for Go4-v2.10-5 by doxygen1.2.15