summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-03-23 17:00:52 +0300
committerAndrei Karas <akaras@inbox.ru>2013-03-23 17:00:52 +0300
commit54897c86bb137dcca72253a0f58899072b3f038d (patch)
tree904df1716580e847cf028e20769aea32aafbc75e /src/utils
parent34cc4ba555814f7907400b4d4b2c5e9fbfa99d22 (diff)
downloadplus-54897c86bb137dcca72253a0f58899072b3f038d.tar.gz
plus-54897c86bb137dcca72253a0f58899072b3f038d.tar.bz2
plus-54897c86bb137dcca72253a0f58899072b3f038d.tar.xz
plus-54897c86bb137dcca72253a0f58899072b3f038d.zip
in profiler save only time from start.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/perfomance.cpp19
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;
}
}