123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- /**
- * @file ResourceStatistics.cpp
- * @brief Iteratively solving linear equation systems with the symmetric LQ (SYMMLQ) method using Lanczos process
- * @author Paul Bodesheim
- * @date 03/02/2012 (dd/mm/yyyy)
- */
- #include "ResourceStatistics.h"
- using namespace NICE;
- using namespace std;
- ResourceStatistics::ResourceStatistics(int _mode)
- {
- mode = _mode;
- }
-
- ResourceStatistics::~ResourceStatistics()
- {
- }
- void ResourceStatistics::getMaximumMemory(long & memory)
- {
- int check = getrusage(mode,&memoryStatistics);
-
- if ( check == -1 )
- {
- fthrow(Exception, "ResourceStatistics::getMaximumMemory: getrusage failed");
- return;
-
- } else if ( check == 0 )
- {
-
- memory = memoryStatistics.ru_maxrss;
- return;
-
- } else
- {
- fthrow(Exception, "ResourceStatistics::getMaximumMemory: unexpected flag");
- return;
-
- }
- }
-
- void ResourceStatistics::getUserCpuTime(double & time)
- {
- int check = getrusage(mode,&memoryStatistics);
-
- if ( check == -1 )
- {
- fthrow(Exception, "ResourceStatistics::getUserCpuTime: getrusage failed");
- return;
-
- } else if ( check == 0 )
- {
-
- double sec = (double) memoryStatistics.ru_utime.tv_sec;
- double msec = (double) memoryStatistics.ru_utime.tv_usec;
- time = sec + (msec/1e6);
- return;
-
- } else
- {
- fthrow(Exception, "ResourceStatistics::getUserCpuTime: unexpected flag");
- return;
-
- }
- }
-
- void ResourceStatistics::getSystemCpuTime(double & time)
- {
- int check = getrusage(mode,&memoryStatistics);
-
- if ( check == -1 )
- {
- fthrow(Exception, "ResourceStatistics::getSystemCpuTime: getrusage failed");
- return;
-
- } else if ( check == 0 )
- {
-
- double sec = (double) memoryStatistics.ru_stime.tv_sec;
- double msec = (double) memoryStatistics.ru_stime.tv_usec;
- time = sec + (msec/1e6);
- return;
-
- } else
- {
- fthrow(Exception, "ResourceStatistics::getSystemCpuTime: unexpected flag");
- return;
-
- }
- }
- void ResourceStatistics::getStatistics(long & memory, double & userCpuTime, double & systemCpuTime)
- {
- int check = getrusage(mode,&memoryStatistics);
-
- if ( check == -1 )
- {
- fthrow(Exception, "ResourceStatistics::getStatistics: getrusage failed");
- return;
-
- } else if ( check == 0 )
- {
- double sec, msec;
-
- memory = memoryStatistics.ru_maxrss;
-
- sec = (double) memoryStatistics.ru_utime.tv_sec;
- msec = (double) memoryStatistics.ru_utime.tv_usec;
- userCpuTime = sec + (msec/1e6);
-
- sec = (double) memoryStatistics.ru_stime.tv_sec;
- msec = (double) memoryStatistics.ru_stime.tv_usec;
- systemCpuTime = sec + (msec/1e6);
-
- return;
-
- } else
- {
- fthrow(Exception, "ResourceStatistics::getStatistics: unexpected flag");
- return;
-
- }
-
-
-
- }
|