summaryrefslogtreecommitdiff
path: root/src/mongo/db/stats/fine_clock.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/stats/fine_clock.h')
-rw-r--r--src/mongo/db/stats/fine_clock.h68
1 files changed, 32 insertions, 36 deletions
diff --git a/src/mongo/db/stats/fine_clock.h b/src/mongo/db/stats/fine_clock.h
index 21f72d212a1..78762b73870 100644
--- a/src/mongo/db/stats/fine_clock.h
+++ b/src/mongo/db/stats/fine_clock.h
@@ -35,45 +35,41 @@
namespace mongo {
- /**
- * This is a nano-second precision clock. We're skipping the
- * harware TSC in favor of clock_gettime() which in some systems
- * does not involve a trip to the OS (VDSO).
- *
- * We're exporting a type WallTime that is and should remain
- * opaque. The business of getting accurate time is still ongoing
- * and we may change the internal representation of this class.
- * (http://lwn.net/Articles/388188/)
- *
- * Really, you shouldn't be using this class in hot code paths for
- * platforms you're not sure whether the overhead is low.
- */
- class FineClock {
- public:
-
- typedef timespec WallTime;
+/**
+ * This is a nano-second precision clock. We're skipping the
+ * harware TSC in favor of clock_gettime() which in some systems
+ * does not involve a trip to the OS (VDSO).
+ *
+ * We're exporting a type WallTime that is and should remain
+ * opaque. The business of getting accurate time is still ongoing
+ * and we may change the internal representation of this class.
+ * (http://lwn.net/Articles/388188/)
+ *
+ * Really, you shouldn't be using this class in hot code paths for
+ * platforms you're not sure whether the overhead is low.
+ */
+class FineClock {
+public:
+ typedef timespec WallTime;
- static WallTime now() {
- struct timespec ts;
- clock_gettime(CLOCK_MONOTONIC, &ts);
- return ts;
- }
+ static WallTime now() {
+ struct timespec ts;
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ return ts;
+ }
- static uint64_t diffInNanos( WallTime end, WallTime start ) {
- uint64_t diff;
- if ( end.tv_nsec < start.tv_nsec ) {
- diff = 1000000000 * ( end.tv_sec - start.tv_sec - 1);
- diff += 1000000000 + end.tv_nsec - start.tv_nsec;
- }
- else {
- diff = 1000000000 * ( end.tv_sec - start.tv_sec );
- diff += end.tv_nsec - start.tv_nsec;
- }
- return diff;
+ static uint64_t diffInNanos(WallTime end, WallTime start) {
+ uint64_t diff;
+ if (end.tv_nsec < start.tv_nsec) {
+ diff = 1000000000 * (end.tv_sec - start.tv_sec - 1);
+ diff += 1000000000 + end.tv_nsec - start.tv_nsec;
+ } else {
+ diff = 1000000000 * (end.tv_sec - start.tv_sec);
+ diff += end.tv_nsec - start.tv_nsec;
}
-
- };
+ return diff;
+ }
+};
}
#endif // DB_STATS_FINE_CLOCK_HEADER
-