Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
267c70c7
Commit
267c70c7
authored
Aug 24, 2011
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gen_server performance test
parent
c3b7b23e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
155 additions
and
0 deletions
+155
-0
gen_server/Makefile
gen_server/Makefile
+7
-0
gen_server/parallel_send.cpp
gen_server/parallel_send.cpp
+82
-0
gen_server/sequential_send.cpp
gen_server/sequential_send.cpp
+66
-0
No files found.
gen_server/Makefile
0 → 100644
View file @
267c70c7
CXX
=
/opt/local/bin/g++-mp-4.6
CXXFLAGS
=
-std
=
c++0x
-pedantic
-Wall
-Wextra
-I
/opt/local/include/
-I
/Users/neverlord/libcppa
-fpermissive
-O2
LIBS
=
-L
/opt/local/lib
-lboost_thread-mt
-L
/Users/neverlord/libcppa/.libs/
-lcppa
all
:
$(CXX)
$(CXXFLAGS)
$(LIBS)
-o
sequential_send sequential_send.cpp
$(CXX)
$(CXXFLAGS)
$(LIBS)
-o
parallel_send parallel_send.cpp
gen_server/parallel_send.cpp
0 → 100644
View file @
267c70c7
#include <iostream>
#include "cppa/cppa.hpp"
#include "cppa/to_string.hpp"
#include "cppa/scheduler.hpp"
#include "cppa/detail/task_scheduler.hpp"
#include <boost/progress.hpp>
using
std
::
cout
;
using
std
::
endl
;
using
boost
::
timer
;
using
namespace
cppa
;
void
counter_actor
()
{
long
count
=
0
;
receive_loop
(
on
<
atom
(
"Get"
)
>
()
>>
[
&
]()
{
reply
(
count
);
count
=
0
;
},
on
<
atom
(
"AddCount"
),
long
>
()
>>
[
&
](
long
val
)
{
count
+=
val
;
}
);
}
constexpr
long
s_val
=
100
;
void
send_range
(
actor_ptr
counter
,
actor_ptr
parent
,
int
from
,
int
to
)
{
for
(
int
i
=
from
;
i
<
to
;
++
i
)
{
send
(
counter
,
atom
(
"AddCount"
),
s_val
);
}
send
(
parent
,
atom
(
"Done"
));
}
long
the_test
(
int
msg_count
)
{
actor_ptr
self_ptr
=
self
();
auto
counter
=
spawn
(
counter_actor
);
for
(
int
i
=
1
;
i
<
(
msg_count
/
1000
);
++
i
)
{
monitor
(
spawn
(
send_range
,
counter
,
self_ptr
,
(
i
-
1
)
*
1000
,
i
*
1000
));
}
auto
rule
=
on
<
atom
(
"Done"
),
any_type
*>
()
>>
[]()
{
};
for
(
int
i
=
1
;
i
<
(
msg_count
/
1000
);
++
i
)
{
receive
(
rule
);
}
send
(
counter
,
atom
(
"Get"
));
long
result
=
0
;
receive
(
on
<
long
>
()
>>
[
&
](
long
value
)
{
result
=
value
;
}
);
send
(
counter
,
atom
(
":Exit"
),
exit_reason
::
user_defined
);
return
result
;
}
void
run_test
(
int
msg_count
)
{
timer
t0
;
long
count
=
the_test
(
msg_count
);
auto
elapsed
=
t0
.
elapsed
();
cout
<<
"Count is "
<<
count
<<
endl
<<
"Test took "
<<
elapsed
<<
" seconds"
<<
endl
<<
"Throughput = "
<<
(
msg_count
/
elapsed
)
<<
" per sec"
<<
endl
;
}
int
main
()
{
run_test
(
3000000
);
return
0
;
}
gen_server/sequential_send.cpp
0 → 100644
View file @
267c70c7
#include <iostream>
#include "cppa/cppa.hpp"
#include "cppa/to_string.hpp"
#include "cppa/scheduler.hpp"
#include "cppa/detail/task_scheduler.hpp"
#include <boost/progress.hpp>
using
std
::
cout
;
using
std
::
endl
;
using
boost
::
timer
;
using
namespace
cppa
;
void
counter_actor
()
{
long
count
=
0
;
receive_loop
(
on
<
atom
(
"Get"
)
>
()
>>
[
&
]()
{
reply
(
count
);
count
=
0
;
},
on
<
atom
(
"AddCount"
),
long
>
()
>>
[
&
](
long
val
)
{
count
+=
val
;
}
);
}
long
the_test
(
int
msg_count
)
{
constexpr
long
val
=
100
;
auto
counter
=
spawn
(
counter_actor
);
for
(
int
i
=
0
;
i
<
msg_count
;
++
i
)
{
send
(
counter
,
atom
(
"AddCount"
),
val
);
}
send
(
counter
,
atom
(
"Get"
));
long
result
=
0
;
receive
(
on
<
long
>
()
>>
[
&
](
long
value
)
{
result
=
value
;
}
);
send
(
counter
,
atom
(
":Exit"
),
exit_reason
::
user_defined
);
return
result
;
}
void
run_test
(
int
msg_count
)
{
timer
t0
;
long
count
=
the_test
(
msg_count
);
auto
elapsed
=
t0
.
elapsed
();
cout
<<
"Count is "
<<
count
<<
endl
<<
"Test took "
<<
elapsed
<<
" seconds"
<<
endl
<<
"Throughput = "
<<
(
msg_count
/
elapsed
)
<<
" per sec"
<<
endl
;
}
int
main
()
{
run_test
(
3000000
);
return
0
;
}
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