From 54897c86bb137dcca72253a0f58899072b3f038d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 23 Mar 2013 17:00:52 +0300 Subject: in profiler save only time from start. --- src/utils/perfomance.cpp | 19 ++++++++++--------- 1 file 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(time.tv_sec) * 1000000000LL \ + + static_cast(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(time.tv_sec) * 1000000000LL - + static_cast(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(time.tv_sec) * 1000000000LL - + static_cast(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(time.tv_sec) * 1000000000LL - + static_cast(time.tv_nsec) - << " end: " << name << std::endl; + file << (timeData - startTime) << " end: " << name << std::endl; } } -- cgit v1.2.3-70-g09d2