[mathicgb] 247/393: Added more precise timing when not using TBB.
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Fri Apr 3 15:59:12 UTC 2015
This is an automated email from the git hooks/post-receive script.
dtorrance-guest pushed a commit to branch upstream
in repository mathicgb.
commit eb80555fddc5822fad8733a2085863674ee9e140
Author: Bjarke Hammersholt Roune <bjarkehr.code at gmail.com>
Date: Sun Apr 14 13:27:56 2013 -0400
Added more precise timing when not using TBB.
---
src/mathicgb/mtbb.hpp | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/src/mathicgb/mtbb.hpp b/src/mathicgb/mtbb.hpp
old mode 100644
new mode 100755
index 00d26a1..e0e313b
--- a/src/mathicgb/mtbb.hpp
+++ b/src/mathicgb/mtbb.hpp
@@ -23,6 +23,7 @@ namespace mgb {
#include <vector>
#include <ctime>
#include <algorithm>
+#include <chrono>
namespace mgb {
namespace tbb {
@@ -194,12 +195,17 @@ namespace mgb {
}
class tick_count {
+ private:
+ // This really should be std::chrono::steady_clock, but GCC 4.5.3 doesn't
+ // have that.
+ typedef std::chrono::system_clock clock;
+
public:
- tick_count(): mTime(0) {}
+ tick_count(): mTime() {}
static tick_count now() {
tick_count t;
- t.mTime = std::time(0);
+ t.mTime = clock::now();
return t;
}
@@ -213,17 +219,19 @@ namespace mgb {
const double mSeconds;
};
- interval_t operator-(tick_count t) const {
- return interval_t(std::difftime(mTime, t.mTime));
+ interval_t operator-(const tick_count t) const {
+ typedef std::chrono::duration<double> SecondDuration;
+ const auto duration =
+ std::chrono::duration_cast<SecondDuration>(mTime - t.mTime);
+ return duration.count();
}
private:
- std::time_t mTime;
+ clock::time_point mTime;
};
}
}
#endif
-
#endif
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mathicgb.git
More information about the debian-science-commits
mailing list