From 464e0d5ed87f5e0c7fa10d13075e62307eba075f Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Tue, 17 Apr 2012 10:48:59 +0200 Subject: Improve efficiency of time measurement in tight loops This patch instantiate a clock_t instance for each XS socket. Thus, it is shared between subsequent calls to xs_recv (and xs_send). That in turn significantly limits the number of invocations of getimeofday (or similar) when timeouts are used and recv/send is called in a tight loop. Signed-off-by: Martin Sustrik --- src/socket_base.hpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/socket_base.hpp') diff --git a/src/socket_base.hpp b/src/socket_base.hpp index 9225ce7..0f7dca8 100644 --- a/src/socket_base.hpp +++ b/src/socket_base.hpp @@ -32,6 +32,7 @@ #include "atomic_counter.hpp" #include "mailbox.hpp" #include "stdint.hpp" +#include "clock.hpp" #include "pipe.hpp" namespace xs @@ -202,6 +203,9 @@ namespace xs // True if the last message received had MORE flag set. bool rcvmore; + // Improves efficiency of time measurement. + clock_t clock; + socket_base_t (const socket_base_t&); const socket_base_t &operator = (const socket_base_t&); }; -- cgit v1.2.3