diff options
author | 2008-03-23 00:05:50 +0000 | |
---|---|---|
committer | 2008-03-23 00:05:50 +0000 | |
commit | f3aaed387116ef94967e1a2cdfa77c175ec9881c (patch) | |
tree | 2916b7ba5a6d03d78081b2a69502f56b805e2dd2 /src/utils.cpp | |
parent | 6c54b4b30b053839d2318cd50dce94c742ee6089 (diff) | |
download | newsboat-f3aaed387116ef94967e1a2cdfa77c175ec9881c.tar.gz newsboat-f3aaed387116ef94967e1a2cdfa77c175ec9881c.tar.zst newsboat-f3aaed387116ef94967e1a2cdfa77c175ec9881c.zip |
Andreas Krennmair:
added transactions to make externalize_rssfeed() faster.
added scope_measure class to make it easier to measure the execution time of code blocks.
Diffstat (limited to '')
-rw-r--r-- | src/utils.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/utils.cpp b/src/utils.cpp index 509bfc32..1ced1cc9 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -571,4 +571,21 @@ std::string utils::absolute_url(const std::string& url, const std::string& link) } } +scope_measure::scope_measure(const std::string& func, loglevel ll) : lvl(ll) { + funcname = func; + gettimeofday(&tv1, NULL); +} + +void scope_measure::stopover(const std::string& son) { + gettimeofday(&tv2, NULL); + unsigned long diff = (((tv2.tv_sec - tv1.tv_sec) * 1000000) + tv2.tv_usec) - tv1.tv_usec; + GetLogger().log(lvl, "scope_measure: function `%s' (stop over `%s') took %lu.%06lu s so far", funcname.c_str(), son.c_str(), diff / 1000000, diff % 1000000); +} + +scope_measure::~scope_measure() { + gettimeofday(&tv2, NULL); + unsigned long diff = (((tv2.tv_sec - tv1.tv_sec) * 1000000) + tv2.tv_usec) - tv1.tv_usec; + GetLogger().log(LOG_INFO, "scope_measure: function `%s' took %lu.%06lu s", funcname.c_str(), diff / 1000000, diff % 1000000); +} + } |