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
32204606
Commit
32204606
authored
May 22, 2015
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(tests): немного переписан sm_perf_test
parent
2f176ef1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
12 deletions
+19
-12
sm_perf_test.cc
extensions/tests/sm_perf_test.cc
+17
-11
sm_perf_test.sh
extensions/tests/sm_perf_test.sh
+2
-1
No files found.
extensions/tests/sm_perf_test.cc
View file @
32204606
#include <memory>
#include <memory>
#include <chrono>
#include <string>
#include <string>
#include "Debug.h"
#include "Debug.h"
#include "UniSetActivator.h"
#include "UniSetActivator.h"
...
@@ -15,6 +16,7 @@ static shared_ptr<SMInterface> smi;
...
@@ -15,6 +16,7 @@ static shared_ptr<SMInterface> smi;
static
shared_ptr
<
SharedMemory
>
shm
;
static
shared_ptr
<
SharedMemory
>
shm
;
static
shared_ptr
<
UInterface
>
ui
;
static
shared_ptr
<
UInterface
>
ui
;
static
ObjectId
myID
=
6000
;
static
ObjectId
myID
=
6000
;
static
ObjectId
begSensorID
=
50000
;
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
shared_ptr
<
SharedMemory
>
shmInstance
()
shared_ptr
<
SharedMemory
>
shmInstance
()
{
{
...
@@ -45,36 +47,35 @@ void run_test(std::size_t concurrency, int bound, shared_ptr<SharedMemory>& shm
...
@@ -45,36 +47,35 @@ void run_test(std::size_t concurrency, int bound, shared_ptr<SharedMemory>& shm
auto
&&
r_worker
=
[
&
shm
,
bound
]
auto
&&
r_worker
=
[
&
shm
,
bound
]
{
{
int
num
=
bound
;
int
num
=
bound
;
ObjectId
sid
=
begSensorID
+
rand
()
%
10000
;
while
(
num
--
)
while
(
num
--
)
{
{
int
v
=
shm
->
getValue
(
11
);
int
v
=
shm
->
getValue
(
sid
);
}
}
};
};
auto
&&
w_worker
=
[
&
shm
,
bound
]
auto
&&
w_worker
=
[
&
shm
,
bound
]
{
{
int
num
=
bound
;
int
num
=
bound
;
ObjectId
sid
=
begSensorID
+
rand
()
%
10000
;
while
(
num
--
)
while
(
num
--
)
{
{
shm
->
setValue
(
11
,
num
);
shm
->
setValue
(
sid
,
num
);
}
}
};
};
std
::
vector
<
std
::
thread
>
threads
;
std
::
vector
<
std
::
thread
>
threads
;
for
(
std
::
size_t
i
=
0
;
i
<
concurrency
-
1
;
++
i
)
for
(
std
::
size_t
i
=
0
;
i
<
concurrency
/
2
-
1
;
++
i
)
{
threads
.
emplace_back
(
r_worker
);
threads
.
emplace_back
(
r_worker
);
}
threads
.
emplace_back
(
w_worker
);
for
(
std
::
size_t
i
=
0
;
i
<
concurrency
/
2
-
1
;
++
i
)
threads
.
emplace_back
(
w_worker
);
for
(
auto
&&
thread
:
threads
)
for
(
auto
&&
thread
:
threads
)
{
thread
.
join
();
thread
.
join
();
}
}
}
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
int
main
(
int
argc
,
char
*
argv
[]
)
int
main
(
int
argc
,
char
*
argv
[]
)
...
@@ -95,7 +96,7 @@ int main(int argc, char* argv[] )
...
@@ -95,7 +96,7 @@ int main(int argc, char* argv[] )
act
->
broadcast
(
sm
.
transport_msg
()
);
act
->
broadcast
(
sm
.
transport_msg
()
);
act
->
run
(
true
);
act
->
run
(
true
);
int
tout
=
6
000
;
int
tout
=
10
000
;
PassiveTimer
pt
(
tout
);
PassiveTimer
pt
(
tout
);
while
(
!
pt
.
checkTime
()
&&
!
act
->
exist
()
)
while
(
!
pt
.
checkTime
()
&&
!
act
->
exist
()
)
...
@@ -107,9 +108,14 @@ int main(int argc, char* argv[] )
...
@@ -107,9 +108,14 @@ int main(int argc, char* argv[] )
return
1
;
return
1
;
}
}
run_test
(
8
,
1000000
,
shm
);
std
::
chrono
::
time_point
<
std
::
chrono
::
system_clock
>
start
,
end
;
start
=
std
::
chrono
::
system_clock
::
now
();
run_test
(
50
,
1000000
,
shm
);
end
=
std
::
chrono
::
system_clock
::
now
();
int
elapsed_seconds
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
end
-
start
).
count
();
std
::
cout
<<
"elapsed time: "
<<
elapsed_seconds
<<
" ms
\n
"
;
return
0
;
return
0
;
}
}
catch
(
const
SystemError
&
err
)
catch
(
const
SystemError
&
err
)
{
{
...
...
extensions/tests/sm_perf_test.sh
View file @
32204606
...
@@ -10,4 +10,5 @@ cd ../../Utilities/Admin/
...
@@ -10,4 +10,5 @@ cd ../../Utilities/Admin/
cd
-
cd
-
time
-p
./uniset2-start.sh
-f
./sm_perf_test
$*
--confile
tests_with_sm.xml
--e-startup-pause
10
#time -p ./uniset2-start.sh -vcall --dump-instr=yes --simulate-cache=yes --collect-jumps=yes ./sm_perf_test $* --confile sm_perf_test.xml --e-startup-pause 10
./uniset2-start.sh
-f
./sm_perf_test
$*
--confile
sm_perf_test.xml
--e-startup-pause
10
>
sm_test_gprof.log
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