Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
7f01e997
Commit
7f01e997
authored
Jun 17, 2010
by
Martin Sustrik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stopwatch returned to libzmq
parent
4777fe40
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
98 additions
and
111 deletions
+98
-111
zmq.h
include/zmq.h
+2
-0
zmq_utils.h
include/zmq_utils.h
+18
-9
Makefile.am
perf/Makefile.am
+4
-5
helpers.cpp
perf/helpers.cpp
+0
-86
local_lat.cpp
perf/local_lat.cpp
+2
-2
local_thr.cpp
perf/local_thr.cpp
+3
-3
remote_lat.cpp
perf/remote_lat.cpp
+3
-3
remote_thr.cpp
perf/remote_thr.cpp
+2
-2
Makefile.am
src/Makefile.am
+1
-1
zmq.cpp
src/zmq.cpp
+63
-0
No files found.
include/zmq.h
View file @
7f01e997
...
...
@@ -223,6 +223,8 @@ ZMQ_EXPORT int zmq_poll (zmq_pollitem_t *items, int nitems, long timeout);
ZMQ_EXPORT
int
zmq_device
(
int
device
,
void
*
insocket
,
void
*
outsocket
);
#undef ZMQ_EXPORT
#ifdef __cplusplus
}
#endif
...
...
perf/helper
s.h
→
include/zmq_util
s.h
View file @
7f01e997
...
...
@@ -17,24 +17,33 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __HELPERS_H_INCLUDED__
#define __HELPERS_H_INCLUDED__
/******************************************************************************/
/* Helper functions. */
/******************************************************************************/
#ifndef __ZMQ_UTILS_H_INCLUDED__
#define __ZMQ_UTILS_H_INCLUDED__
/* Win32 needs special handling for DLL exports */
#if defined _WIN32
# if defined DLL_EXPORT
# define ZMQ_EXPORT __declspec(dllexport)
# else
# define ZMQ_EXPORT __declspec(dllimport)
# endif
#else
# define ZMQ_EXPORT
#endif
/* Helper functions are used by perf tests so that they don't have to care */
/* about minutiae of time-related functions on different OS platforms. */
/* Starts the stopwatch. Returns the handle to the watch. */
void
*
stopwatch_start
();
ZMQ_EXPORT
void
*
zmq_
stopwatch_start
();
/* Stops the stopwatch. Returns the number of microseconds elapsed since */
/* the stopwatch was started. */
unsigned
long
stopwatch_stop
(
void
*
watch_
);
ZMQ_EXPORT
unsigned
long
zmq_
stopwatch_stop
(
void
*
watch_
);
/* Sleeps for specified number of seconds. */
void
perf_sleep
(
int
seconds_
);
ZMQ_EXPORT
void
zmq_sleep
(
int
seconds_
);
#undef ZMQ_EXPORT
#endif
perf/Makefile.am
View file @
7f01e997
INCLUDES
=
-I
$(top_builddir)
/include
noinst_PROGRAMS
=
local_lat remote_lat local_thr remote_thr
EXTRA_DIST
=
helpers.h
local_lat_LDADD
=
$(top_builddir)
/src/libzmq.la
local_lat_SOURCES
=
local_lat.cpp
helpers.cpp
local_lat_SOURCES
=
local_lat.cpp
remote_lat_LDADD
=
$(top_builddir)
/src/libzmq.la
remote_lat_SOURCES
=
remote_lat.cpp
helpers.cpp
remote_lat_SOURCES
=
remote_lat.cpp
local_thr_LDADD
=
$(top_builddir)
/src/libzmq.la
local_thr_SOURCES
=
local_thr.cpp
helpers.cpp
local_thr_SOURCES
=
local_thr.cpp
remote_thr_LDADD
=
$(top_builddir)
/src/libzmq.la
remote_thr_SOURCES
=
remote_thr.cpp
helpers.cpp
remote_thr_SOURCES
=
remote_thr.cpp
perf/helpers.cpp
deleted
100644 → 0
View file @
4777fe40
/*
Copyright (c) 2007-2010 iMatix Corporation
This file is part of 0MQ.
0MQ is free software; you can redistribute it and/or modify it under
the terms of the Lesser GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
0MQ is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Lesser GNU General Public License for more details.
You should have received a copy of the Lesser GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <assert.h>
#include <stdlib.h>
#ifdef _WIN32
# include "../src/windows.hpp"
#else
# include <sys/time.h>
# include <unistd.h>
#endif
#include "../src/stdint.hpp"
#ifdef _WIN32
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
perf_sleep
(
int
seconds_
)
{
Sleep
(
seconds_
*
1000
);
}
#else
/* not _WIN32 */
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
perf_sleep
(
int
seconds_
)
{
sleep
(
seconds_
);
}
#endif
/* _WIN32 */
void
*
stopwatch_start
()
{
uint64_t
*
watch
=
(
uint64_t
*
)
malloc
(
sizeof
(
uint64_t
));
assert
(
watch
);
*
watch
=
now
();
return
(
void
*
)
watch
;
}
unsigned
long
stopwatch_stop
(
void
*
watch_
)
{
uint64_t
end
=
now
();
uint64_t
start
=
*
(
uint64_t
*
)
watch_
;
free
(
watch_
);
return
(
unsigned
long
)
(
end
-
start
);
}
perf/local_lat.cpp
View file @
7f01e997
...
...
@@ -18,9 +18,9 @@
*/
#include "../include/zmq.h"
#include "../include/zmq_utils.h"
#include <stdio.h>
#include <stdlib.h>
#include "helpers.h"
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -89,7 +89,7 @@ int main (int argc, char *argv [])
return
-
1
;
}
perf
_sleep
(
1
);
zmq
_sleep
(
1
);
rc
=
zmq_close
(
s
);
if
(
rc
!=
0
)
{
...
...
perf/local_thr.cpp
View file @
7f01e997
...
...
@@ -18,9 +18,9 @@
*/
#include "../include/zmq.h"
#include "../include/zmq_utils.h"
#include <stdio.h>
#include <stdlib.h>
#include "helpers.h"
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -88,7 +88,7 @@ int main (int argc, char *argv [])
return
-
1
;
}
watch
=
stopwatch_start
();
watch
=
zmq_
stopwatch_start
();
for
(
i
=
0
;
i
!=
message_count
-
1
;
i
++
)
{
rc
=
zmq_recv
(
s
,
&
msg
,
0
);
...
...
@@ -102,7 +102,7 @@ int main (int argc, char *argv [])
}
}
elapsed
=
stopwatch_stop
(
watch
);
elapsed
=
zmq_
stopwatch_stop
(
watch
);
if
(
elapsed
==
0
)
elapsed
=
1
;
...
...
perf/remote_lat.cpp
View file @
7f01e997
...
...
@@ -18,10 +18,10 @@
*/
#include "../include/zmq.h"
#include "../include/zmq_utils.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "helpers.h"
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -71,7 +71,7 @@ int main (int argc, char *argv [])
}
memset
(
zmq_msg_data
(
&
msg
),
0
,
message_size
);
watch
=
stopwatch_start
();
watch
=
zmq_
stopwatch_start
();
for
(
i
=
0
;
i
!=
roundtrip_count
;
i
++
)
{
rc
=
zmq_send
(
s
,
&
msg
,
0
);
...
...
@@ -90,7 +90,7 @@ int main (int argc, char *argv [])
}
}
elapsed
=
stopwatch_stop
(
watch
);
elapsed
=
zmq_
stopwatch_stop
(
watch
);
rc
=
zmq_msg_close
(
&
msg
);
if
(
rc
!=
0
)
{
...
...
perf/remote_thr.cpp
View file @
7f01e997
...
...
@@ -18,9 +18,9 @@
*/
#include "../include/zmq.h"
#include "../include/zmq_utils.h"
#include <stdio.h>
#include <stdlib.h>
#include "helpers.h"
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -81,7 +81,7 @@ int main (int argc, char *argv [])
}
}
perf
_sleep
(
10
);
zmq
_sleep
(
10
);
rc
=
zmq_close
(
s
);
if
(
rc
!=
0
)
{
...
...
src/Makefile.am
View file @
7f01e997
...
...
@@ -3,7 +3,7 @@ lib_LTLIBRARIES = libzmq.la
pkgconfigdir
=
$(libdir)
/pkgconfig
pkgconfig_DATA
=
libzmq.pc
include_HEADERS
=
../include/zmq.h ../include/zmq.hpp
include_HEADERS
=
../include/zmq.h ../include/zmq.hpp
../include/zmq_utils.h
if
BUILD_PGM
pgm_sources
=
../foreign/openpgm/@pgm_basename@/openpgm/pgm/packet.c
\
...
...
src/zmq.cpp
View file @
7f01e997
...
...
@@ -661,3 +661,66 @@ int zmq_device (int device_, void *insocket_, void *outsocket_)
return
EINVAL
;
}
}
////////////////////////////////////////////////////////////////////////////////
// 0MQ utils - to be used by perf tests
////////////////////////////////////////////////////////////////////////////////
#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
));
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
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment