Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
ipgallery.common.cpp
/
Microservice
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Registry
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e3d315e5
authored
Mar 28, 2017
by
amir
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add commonutils
parent
bb9ac7a2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
1 deletions
src/utils/CommonUtils.h
test/Microservice_ZMQTest.cpp
src/utils/CommonUtils.h
0 → 100644
View file @
e3d315e5
//
// Created by amir on 28/03/17.
//
#ifndef MICROSERVICE_COMMONUTILS_H
#define MICROSERVICE_COMMONUTILS_H
#include <chrono>
#include <utility>
/**
* common utils
*/
class
CommonUtils
{
public
:
/**
* measuring execution of a function
* @tparam TimeT time unit (default milliseconds)
* @param func function
* @param args function args
* @return
*/
template
<
typename
TimeT
=
std
::
chrono
::
milliseconds
,
typename
F
,
typename
...
Args
>
static
typename
TimeT
::
rep
measureFunc
(
F
&&
func
,
Args
&&
...
args
)
{
auto
start
=
std
::
chrono
::
steady_clock
::
now
();
std
::
forward
<
decltype
(
func
)
>
(
func
)(
std
::
forward
<
Args
>
(
args
)...);
auto
duration
=
std
::
chrono
::
duration_cast
<
TimeT
>
(
std
::
chrono
::
steady_clock
::
now
()
-
start
);
return
duration
.
count
();
}
};
#endif //MICROSERVICE_COMMONUTILS_H
test/Microservice_ZMQTest.cpp
View file @
e3d315e5
...
...
@@ -8,6 +8,7 @@
#include <iostream>
#include <common/Microservice_MsgQContext.h>
#include <thread>
#include <utils/CommonUtils.h>
static
const
char
*
const
IPC_FILE1
=
"/tmp/service-name1.ipc"
;
static
const
char
*
const
IPC_FILE2
=
"/tmp/service-name2.ipc"
;
...
...
@@ -239,7 +240,9 @@ void test_pubsub(zmqpp::context &context) {
int
main
(
int
argc
,
char
*
argv
[])
{
zmqpp
::
context
context
;
std
::
cout
<<
"testing of "
<<
ITERATIONS
<<
" iterations took: "
<<
measure
<>::
execution
(
testRequestResponse
,
context
)
<<
" msec"
<<
std
::
endl
;
// std::cout << "testing of " << ITERATIONS << " iterations took: " << measure<>::execution(testRequestResponse,context) << " msec" << std::endl;
std
::
cout
<<
"testing of "
<<
ITERATIONS
<<
" iterations took: "
<<
CommonUtils
::
measureFunc
<>
(
testRequestResponse
,
context
)
<<
" msec"
<<
std
::
endl
;
//testRequestResponse(context);
//test_pubsub(context);
//test_Cereal();
...
...
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