summaryrefslogtreecommitdiff
path: root/src/xs.cpp
diff options
context:
space:
mode:
authorMartin Lucina <martin@lucina.net>2012-03-13 12:30:49 +0100
committerMartin Lucina <martin@lucina.net>2012-03-13 12:30:49 +0100
commit67c0bc5092cde58fc33205a29ccad6b8230104db (patch)
treee3ab3195f9192ee6d0ddcaa1c6bd773cbfad5097 /src/xs.cpp
parent5749a18faea208ad19f39612c3c55166ca409fef (diff)
xs_utils cleanup 2/2 (remove xs_utils.h)
Moved xs_stopwatch_* functions from xs_utils.cpp/xs_utils.h, and removed those files. This leaves us with a single header file for libxs. Signed-off-by: Martin Lucina <martin@lucina.net>
Diffstat (limited to 'src/xs.cpp')
-rw-r--r--src/xs.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/xs.cpp b/src/xs.cpp
index b90e383..36d40da 100644
--- a/src/xs.cpp
+++ b/src/xs.cpp
@@ -37,6 +37,7 @@
#include "config.hpp"
#include "likely.hpp"
#include "upoll.hpp"
+#include "clock.hpp"
#include "ctx.hpp"
#include "err.hpp"
#include "msg.hpp"
@@ -356,4 +357,24 @@ int xs_errno ()
return errno;
}
+// The following utility functions are exported for use from language bindings
+// in performance tests, for the purpose of consistent results in such tests.
+// They are not considered part of the core XS API per se, use at your own
+// risk!
+
+void *xs_stopwatch_start ()
+{
+ uint64_t *watch = (uint64_t*) malloc (sizeof (uint64_t));
+ alloc_assert (watch);
+ *watch = xs::clock_t::now_us ();
+ return (void*) watch;
+}
+
+unsigned long xs_stopwatch_stop (void *watch_)
+{
+ uint64_t end = xs::clock_t::now_us ();
+ uint64_t start = *(uint64_t*) watch_;
+ free (watch_);
+ return (unsigned long) (end - start);
+}