Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
5edbe776
Commit
5edbe776
authored
May 03, 2015
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Добавил тесты для проверки "производительности" (SM)
parent
e2cbeb0b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
214 additions
and
1 deletion
+214
-1
Makefile.am
extensions/tests/Makefile.am
+8
-1
sm_perf_test.cc
extensions/tests/sm_perf_test.cc
+120
-0
sm_perf_test.sh
extensions/tests/sm_perf_test.sh
+13
-0
perf_test.cc
tests/perf_test.cc
+69
-0
perf_test.sh
tests/perf_test.sh
+4
-0
No files found.
extensions/tests/Makefile.am
View file @
5edbe776
SUBDIR
=
SMemoryTest
if
HAVE_TESTS
noinst_PROGRAMS
=
tests tests_with_conf tests_with_sm
noinst_PROGRAMS
=
tests tests_with_conf tests_with_sm
sm_perf_test
tests_SOURCES
=
tests.cc test_digitalfilter.cc test_vtypes.cc
tests_LDADD
=
$(top_builddir)
/lib/libUniSet2.la
$(top_builddir)
/extensions/lib/libUniSet2Extensions.la
...
...
@@ -18,6 +18,13 @@ tests_with_sm_CPPFLAGS = -I$(top_builddir)/include -I$(top_builddir)/extensions
-I
$(top_builddir)
/extensions/SharedMemory
$(SIGC_CFLAGS)
$(COMCPP_CFLAGS)
sm_perf_test_SOURCES
=
sm_perf_test.cc
sm_perf_test_LDADD
=
$(top_builddir)
/lib/libUniSet2.la
$(top_builddir)
/extensions/lib/libUniSet2Extensions.la
\
$(top_builddir)
/extensions/SharedMemory/libUniSet2SharedMemory.la
$(SIGC_LIBS)
$(COMCPP_LIBS)
sm_perf_test_CPPFLAGS
=
-I
$(top_builddir)
/include
-I
$(top_builddir)
/extensions/include
\
-I
$(top_builddir)
/extensions/SharedMemory
$(SIGC_CFLAGS)
$(COMCPP_CFLAGS)
include
$(top_builddir)/testsuite/testsuite-common.mk
check-local
:
atconfig package.m4 $(TESTSUITE)
...
...
extensions/tests/sm_perf_test.cc
0 → 100644
View file @
5edbe776
#include <memory>
#include <string>
#include "Debug.h"
#include "UniSetActivator.h"
#include "PassiveTimer.h"
#include "SharedMemory.h"
#include "SMInterface.h"
#include "Extensions.h"
// --------------------------------------------------------------------------
using
namespace
std
;
using
namespace
UniSetTypes
;
using
namespace
UniSetExtensions
;
// --------------------------------------------------------------------------
static
shared_ptr
<
SMInterface
>
smi
;
static
shared_ptr
<
SharedMemory
>
shm
;
static
shared_ptr
<
UInterface
>
ui
;
static
ObjectId
myID
=
6000
;
// --------------------------------------------------------------------------
shared_ptr
<
SharedMemory
>
shmInstance
()
{
if
(
!
shm
)
throw
SystemError
(
"SharedMemory don`t initialize.."
);
return
shm
;
}
// --------------------------------------------------------------------------
shared_ptr
<
SMInterface
>
smiInstance
()
{
if
(
smi
==
nullptr
)
{
if
(
shm
==
nullptr
)
throw
SystemError
(
"SharedMemory don`t initialize.."
);
if
(
ui
==
nullptr
)
ui
=
make_shared
<
UInterface
>
();
smi
=
make_shared
<
SMInterface
>
(
shm
->
getId
(),
ui
,
myID
,
shm
);
}
return
smi
;
}
// --------------------------------------------------------------------------
void
run_test
(
std
::
size_t
concurrency
,
int
bound
,
shared_ptr
<
SharedMemory
>&
shm
)
{
auto
&&
r_worker
=
[
&
shm
,
bound
]
{
int
num
=
bound
;
while
(
num
--
)
{
shm
->
getValue
(
11
);
}
};
auto
&&
w_worker
=
[
&
shm
,
bound
]
{
int
num
=
bound
;
while
(
num
--
)
{
shm
->
setValue
(
11
,
123
);
}
};
std
::
vector
<
std
::
thread
>
threads
;
for
(
std
::
size_t
i
=
0
;
i
<
concurrency
;
++
i
)
{
threads
.
emplace_back
(
r_worker
);
}
threads
.
emplace_back
(
w_worker
);
for
(
auto
&&
thread
:
threads
)
{
thread
.
join
();
}
}
// --------------------------------------------------------------------------
int
main
(
int
argc
,
char
*
argv
[]
)
{
try
{
auto
conf
=
uniset_init
(
argc
,
argv
);
shm
=
SharedMemory
::
init_smemory
(
argc
,
argv
);
if
(
!
shm
)
return
1
;
auto
act
=
UniSetActivator
::
Instance
();
act
->
add
(
shm
);
SystemMessage
sm
(
SystemMessage
::
StartUp
);
act
->
broadcast
(
sm
.
transport_msg
()
);
act
->
run
(
true
);
int
tout
=
6000
;
PassiveTimer
pt
(
tout
);
while
(
!
pt
.
checkTime
()
&&
!
act
->
exist
()
)
msleep
(
100
);
if
(
!
act
->
exist
()
)
{
cerr
<<
"(tests_with_sm): SharedMemory not exist! (timeout="
<<
tout
<<
")"
<<
endl
;
return
1
;
}
run_test
(
8
,
1000000
,
shm
);
return
0
;
}
catch
(
const
SystemError
&
err
)
{
cerr
<<
"(tests_with_sm): "
<<
err
<<
endl
;
}
catch
(
const
Exception
&
ex
)
{
cerr
<<
"(tests_with_sm): "
<<
ex
<<
endl
;
}
catch
(
const
std
::
exception
&
e
)
{
cerr
<<
"(tests_with_sm): "
<<
e
.
what
()
<<
endl
;
}
catch
(...)
{
cerr
<<
"(tests_with_sm): catch(...)"
<<
endl
;
}
return
1
;
}
extensions/tests/sm_perf_test.sh
0 → 100755
View file @
5edbe776
#!/bin/sh
# '--' - нужен для отделения аргументов catch, от наших..
cd
../../Utilities/Admin/
./create_links.sh
./uniset2-start.sh
-f
./create
./uniset2-start.sh
-f
./exist |
grep
-q
UNISET_PLC/Controllers
||
exit
1
cd
-
time
-p
./uniset2-start.sh
-f
./sm_perf_test
$*
--confile
tests_with_sm.xml
--e-startup-pause
10
tests/perf_test.cc
0 → 100644
View file @
5edbe776
#include <map>
#include <unordered_map>
#include <vector>
#include <iostream>
#include <iomanip>
#include "Configuration.h"
using
namespace
std
;
std
::
map
<
UniSetTypes
::
ObjectId
,
int
>
std_m
;
std
::
unordered_map
<
UniSetTypes
::
ObjectId
,
int
>
std_un
;
std
::
vector
<
UniSetTypes
::
ObjectId
>
values
;
const
int
N
=
10000000
;
int
main
(
int
argc
,
char
*
argv
[]
)
{
auto
conf
=
UniSetTypes
::
uniset_init
(
argc
,
argv
);
auto
ind
=
conf
->
oind
;
int
t1
,
t2
;
for
(
int
i
=
0
;
i
<
N
;
i
++
)
values
.
push_back
(
rand
()
*
rand
()
);
#if 0
std::cout << "insert:" << std::endl;
for ( int k = 0; k < 5; k++ ) {
t1 = clock();
for ( int i = 0; i < N; i++ )
std_m[ values[ i ] ] = i;
t2 = clock();
std::cout << "std : " << std::setw( 8 ) << (t2 - t1) / (double)CLOCKS_PER_SEC * 1000 << " ms." << std::endl;
}
for ( int k = 0; k < 5; k++ ) {
t1 = clock();
for ( int i = 0; i < N; i++ )
std_un[ values[ i ] ] = i;
t2 = clock();
std::cout << "std_un: " << std::setw( 8 ) << (t2 - t1) / (double)CLOCKS_PER_SEC * 1000 << " ms." << std::endl;
}
#endif
std
::
cout
<<
"find:"
<<
std
::
endl
;
{
t1
=
clock
();
for
(
int
k
=
0
;
k
<
N
;
k
++
)
{
auto
v
=
std_m
.
find
(
rand
()
);
}
t2
=
clock
();
std
::
cout
<<
"std : "
<<
std
::
setw
(
8
)
<<
(
t2
-
t1
)
/
(
double
)
CLOCKS_PER_SEC
*
1000
<<
" ms."
<<
std
::
endl
;
}
{
t1
=
clock
();
for
(
int
k
=
0
;
k
<
N
;
k
++
)
{
auto
v
=
std_un
.
find
(
rand
()
);
}
t2
=
clock
();
std
::
cout
<<
"std_un: "
<<
std
::
setw
(
8
)
<<
(
t2
-
t1
)
/
(
double
)
CLOCKS_PER_SEC
*
1000
<<
" ms."
<<
std
::
endl
;
}
return
0
;
}
tests/perf_test.sh
0 → 100755
View file @
5edbe776
#!/bin/sh
# '--' - нужен для отделения аоргументов catch, от наших..
./perf_test
$*
--
--confile
tests_with_conf.xml
--prop-id2
-10
--ulog-no-debug
&&
exit
0
||
exit
1
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