diff options
author | Martin Lucina <mato@kotelna.sk> | 2010-06-04 14:48:49 +0200 |
---|---|---|
committer | Martin Lucina <mato@kotelna.sk> | 2010-06-04 14:48:49 +0200 |
commit | 606c77368cccd2a277437b5de8764772295fdf89 (patch) | |
tree | 93d3a40130b80af1bd04c38973a7d8398e2e7021 /src | |
parent | 05b4a7ae787760d5c24e048612b786fa0283854a (diff) |
Move perf helper functions to perf/helpers.cpp
Diffstat (limited to 'src')
-rw-r--r-- | src/zmq.cpp | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/src/zmq.cpp b/src/zmq.cpp index 5f0b8ea..c32fd65 100644 --- a/src/zmq.cpp +++ b/src/zmq.cpp @@ -663,61 +663,3 @@ int zmq_device (int device_, void *insocket_, void *outsocket_) return EINVAL; } } - -#if defined ZMQ_HAVE_WINDOWS - -static uint64_t now () -{ - // Get the high resolution counter's accuracy. - LARGE_INTEGER ticksPerSecond; - QueryPerformanceFrequency (&ticksPerSecond); - - // What time is it? - LARGE_INTEGER tick; - QueryPerformanceCounter (&tick); - - // Convert the tick number into the number of seconds - // since the system was started. - double ticks_div = (double) (ticksPerSecond.QuadPart / 1000000); - return (uint64_t) (tick.QuadPart / ticks_div); -} - -void zmq_sleep (int seconds_) -{ - Sleep (seconds_ * 1000); -} - -#else - -static uint64_t now () -{ - struct timeval tv; - int rc; - - rc = gettimeofday (&tv, NULL); - assert (rc == 0); - return (tv.tv_sec * (uint64_t) 1000000 + tv.tv_usec); -} - -void zmq_sleep (int seconds_) -{ - sleep (seconds_); -} - -#endif - -void *zmq_stopwatch_start () -{ - uint64_t *watch = (uint64_t*) malloc (sizeof (uint64_t)); - zmq_assert (watch); - *watch = now (); - return (void*) watch; -} - -unsigned long zmq_stopwatch_stop (void *watch_) -{ - uint64_t end = now (); - uint64_t start = *(uint64_t*) watch_; - free (watch_); - return (unsigned long) (end - start); -} |