diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-03-23 17:00:52 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-03-23 17:00:52 +0300 |
commit | 54897c86bb137dcca72253a0f58899072b3f038d (patch) | |
tree | 904df1716580e847cf028e20769aea32aafbc75e /src/utils | |
parent | 34cc4ba555814f7907400b4d4b2c5e9fbfa99d22 (diff) | |
download | mv-54897c86bb137dcca72253a0f58899072b3f038d.tar.gz mv-54897c86bb137dcca72253a0f58899072b3f038d.tar.bz2 mv-54897c86bb137dcca72253a0f58899072b3f038d.tar.xz mv-54897c86bb137dcca72253a0f58899072b3f038d.zip |
in profiler save only time from start.
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/perfomance.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/utils/perfomance.cpp b/src/utils/perfomance.cpp index 5114906d5..725022f8e 100644 --- a/src/utils/perfomance.cpp +++ b/src/utils/perfomance.cpp @@ -39,13 +39,20 @@ //static const clockid_t clockType = CLOCK_PROCESS_CPUTIME_ID; static const clockid_t clockType = CLOCK_MONOTONIC; +#define timeData (static_cast<long long int>(time.tv_sec) * 1000000000LL \ + + static_cast<long long int>(time.tv_nsec)) + namespace Perfomance { std::ofstream file; + long long unsigned int startTime; void init(const std::string &path) { file.open(path.c_str(), std::ios_base::trunc); + timespec time; + clock_gettime(clockType, &time); + startTime = timeData; } void clear() @@ -58,27 +65,21 @@ namespace Perfomance { timespec time; clock_gettime(clockType, &time); - file << static_cast<long long int>(time.tv_sec) * 1000000000LL - + static_cast<long long int>(time.tv_nsec) - << " __init__" << std::endl; + file << (timeData - startTime) << " __init__" << std::endl; } void blockStart(const std::string &name) { timespec time; clock_gettime(clockType, &time); - file << static_cast<long long int>(time.tv_sec) * 1000000000LL - + static_cast<long long int>(time.tv_nsec) - << " start: " << name << std::endl; + file << (timeData - startTime) << " start: " << name << std::endl; } void blockEnd(const std::string &name) { timespec time; clock_gettime(clockType, &time); - file << static_cast<long long int>(time.tv_sec) * 1000000000LL - + static_cast<long long int>(time.tv_nsec) - << " end: " << name << std::endl; + file << (timeData - startTime) << " end: " << name << std::endl; } } |