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
28ad1a22
Commit
28ad1a22
authored
Jan 07, 2012
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
theron benchmark
parent
8e8dd869
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
0 deletions
+77
-0
benchmarks/theron_mailbox_performance.cpp
benchmarks/theron_mailbox_performance.cpp
+77
-0
No files found.
benchmarks/theron_mailbox_performance.cpp
0 → 100644
View file @
28ad1a22
#define THERON_USE_BOOST_THREADS 1
#include <Theron/Framework.h>
#include <Theron/Actor.h>
#include <iostream>
#include <thread>
#include <cstdint>
using
std
::
cerr
;
using
std
::
cout
;
using
std
::
endl
;
using
std
::
int64_t
;
// A trivial actor that does nothing.
struct
receiver
:
Theron
::
Actor
{
int64_t
m_max
;
int64_t
m_num
;
Theron
::
Address
m_waiter
;
typedef
struct
{
int64_t
arg1
;
Theron
::
Address
arg2
;
}
Parameters
;
void
handler
(
int64_t
const
&
,
Theron
::
Address
)
{
if
(
++
m_num
==
m_max
)
Send
(
m_max
,
m_waiter
);
}
//receiver(int64_t max, Theron::Address waiter) : m_max(max), m_num(0), m_waiter(waiter)
receiver
(
Parameters
const
&
p
)
:
m_max
(
p
.
arg1
),
m_num
(
0
),
m_waiter
(
p
.
arg2
)
{
RegisterHandler
(
this
,
&
receiver
::
handler
);
}
}
;
void
sender
(
Theron
::
ActorRef
ref
,
int64_t
num
)
{
int64_t
msg
;
for
(
int64_t
i
=
0
;
i
<
num
;
++
i
)
{
ref
.
Push
(
msg
,
ref
.
GetAddress
());
}
}
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
!=
3
)
{
cout
<<
"usage (num_threads) (num_messages)"
<<
endl
;
return
1
;
}
char
*
endptr
=
nullptr
;
int64_t
num_sender
=
static_cast
<
int64_t
>
(
strtol
(
argv
[
1
],
&
endptr
,
10
));
if
(
endptr
==
nullptr
||
*
endptr
!=
'\0'
)
{
cerr
<<
"
\"
"
<<
argv
[
1
]
<<
"
\"
is not an integer"
<<
endl
;
return
1
;
}
int64_t
num_msgs
=
static_cast
<
int64_t
>
(
strtol
(
argv
[
2
],
&
endptr
,
10
));
if
(
endptr
==
nullptr
||
*
endptr
!=
'\0'
)
{
cerr
<<
"
\"
"
<<
argv
[
2
]
<<
"
\"
is not an integer"
<<
endl
;
return
1
;
}
Theron
::
Receiver
r
;
Theron
::
Framework
framework
;
Theron
::
ActorRef
aref
(
framework
.
CreateActor
<
receiver
>
(
receiver
::
Parameters
{
num_sender
*
num_msgs
,
r
.
GetAddress
()}));
for
(
int64_t
i
=
0
;
i
<
num_sender
;
++
i
)
{
std
::
thread
(
sender
,
aref
,
num_msgs
).
detach
();
}
r
.
Wait
();
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