00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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
00074
00075 return 0;
00076 }
00077
00078 void usage()
00079 {
00080 cout << "Usage: ProfileTimer #number sleep\n";
00081 exit(1);
00082 }
00083
00084