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
b33b7052
Commit
b33b7052
authored
Jan 21, 2012
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
benchmark update
parent
508ab179
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
215 additions
and
103 deletions
+215
-103
benchmarks/actor_creation.cpp
benchmarks/actor_creation.cpp
+1
-17
benchmarks/mailbox_performance.cpp
benchmarks/mailbox_performance.cpp
+1
-17
benchmarks/matching.erl
benchmarks/matching.erl
+26
-0
benchmarks/mixed_case.cpp
benchmarks/mixed_case.cpp
+1
-17
benchmarks/theron_actor_creation.cpp
benchmarks/theron_actor_creation.cpp
+99
-0
benchmarks/theron_mailbox_performance.cpp
benchmarks/theron_mailbox_performance.cpp
+31
-51
benchmarks/utility.hpp
benchmarks/utility.hpp
+52
-0
cppa.files
cppa.files
+4
-0
cppa/detail/matches.hpp
cppa/detail/matches.hpp
+0
-1
No files found.
benchmarks/actor_creation.cpp
View file @
b33b7052
...
...
@@ -33,6 +33,7 @@
#include <cstring>
#include <iostream>
#include "utility.hpp"
#include "cppa/cppa.hpp"
#include "cppa/fsm_actor.hpp"
...
...
@@ -117,23 +118,6 @@ void usage()
<<
endl
;
}
template
<
typename
T
>
T
rd
(
char
const
*
cstr
)
{
char
*
endptr
=
nullptr
;
T
result
=
static_cast
<
T
>
(
strtol
(
cstr
,
&
endptr
,
10
));
if
(
endptr
==
nullptr
||
*
endptr
!=
'\0'
)
{
std
::
string
errstr
;
errstr
+=
"
\"
"
;
errstr
+=
cstr
;
errstr
+=
"
\"
is not an integer"
;
usage
();
throw
std
::
invalid_argument
(
errstr
);
}
return
result
;
}
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
==
3
)
...
...
benchmarks/mailbox_performance.cpp
View file @
b33b7052
...
...
@@ -33,6 +33,7 @@
#include <cstring>
#include <iostream>
#include "utility.hpp"
#include "cppa/cppa.hpp"
#include "cppa/fsm_actor.hpp"
#include "cppa/detail/thread.hpp"
...
...
@@ -92,23 +93,6 @@ void usage()
<<
endl
;
}
template
<
typename
T
>
T
rd
(
char
const
*
cstr
)
{
char
*
endptr
=
nullptr
;
T
result
=
static_cast
<
T
>
(
strtol
(
cstr
,
&
endptr
,
10
));
if
(
endptr
==
nullptr
||
*
endptr
!=
'\0'
)
{
std
::
string
errstr
;
errstr
+=
"
\"
"
;
errstr
+=
cstr
;
errstr
+=
"
\"
is not an integer"
;
usage
();
throw
std
::
invalid_argument
(
errstr
);
}
return
result
;
}
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
==
4
)
...
...
benchmarks/matching.erl
0 → 100644
View file @
b33b7052
-
module
(
matching
).
-
export
([
start
/
1
]).
partFun
(
msg1
,
X
)
when
X
=:=
0
->
true
;
partFun
(
msg2
,
0
.
0
)
->
true
;
partFun
(
msg3
,
[
0
|[]])
->
true
.
partFun
(
msg4
,
0
,
"0"
)
->
true
.
partFun
(
msg5
,
A
,
B
,
C
)
when
A
=:=
0
;
B
=:=
0
;
C
=:=
0
->
true
;
partFun
(
msg6
,
A
,
0
.
0
,
"0"
)
when
A
=:=
0
->
true
.
loop
(
0
)
->
true
;
loop
(
N
)
->
partFun
(
msg1
,
0
),
partFun
(
msg2
,
0
.
0
),
partFun
(
msg3
,
[
0
]),
partFun
(
msg4
,
0
,
"0"
),
partFun
(
msg5
,
0
,
0
,
0
),
partFun
(
msg6
,
0
,
0
.
0
,
"0"
),
loop
(
N
-
1
).
start
(
X
)
->
[
H
|[]]
=
X
,
N
=
list_to_integer
(
atom_to_list
(
H
)),
loop
(
N
).
benchmarks/mixed_case.cpp
View file @
b33b7052
...
...
@@ -33,6 +33,7 @@
#include <cstring>
#include <iostream>
#include "utility.hpp"
#include "cppa/cppa.hpp"
#include "cppa/fsm_actor.hpp"
...
...
@@ -315,23 +316,6 @@ void usage()
<<
endl
;
}
template
<
typename
T
>
T
rd
(
char
const
*
cstr
)
{
char
*
endptr
=
nullptr
;
T
result
=
static_cast
<
T
>
(
strtol
(
cstr
,
&
endptr
,
10
));
if
(
endptr
==
nullptr
||
*
endptr
!=
'\0'
)
{
std
::
string
errstr
;
errstr
+=
"
\"
"
;
errstr
+=
cstr
;
errstr
+=
"
\"
is not an integer"
;
usage
();
throw
std
::
invalid_argument
(
errstr
);
}
return
result
;
}
int
main
(
int
argc
,
char
**
argv
)
{
announce
<
factors
>
();
...
...
benchmarks/theron_actor_creation.cpp
0 → 100644
View file @
b33b7052
#define THERON_USE_BOOST_THREADS 1
#include <Theron/Framework.h>
#include <Theron/Actor.h>
#include <thread>
#include <cstdint>
#include <iostream>
#include <functional>
#include "utility.hpp"
using
std
::
cerr
;
using
std
::
cout
;
using
std
::
endl
;
using
std
::
int64_t
;
using
std
::
uint32_t
;
using
namespace
Theron
;
struct
spread
{
int
value
;
};
struct
result
{
uint32_t
value
;
};
THERON_REGISTER_MESSAGE
(
spread
);
THERON_REGISTER_MESSAGE
(
result
);
template
<
typename
RefType
>
struct
testee_base
:
Actor
;
struct
testee
:
testee_base
<
RefType
>
{
typedef
struct
{
Address
arg0
;
}
Parameters
;
Address
m_parent
;
bool
m_first_result_received
;
uint32_t
m_first_result
;
std
::
vector
<
RefType
>
m_children
;
void
spread_handler
(
spread
const
&
arg
,
const
Address
)
{
if
(
arg
.
value
==
0
)
{
Send
(
result
{
1
},
m_parent
);
}
else
{
spread
msg
=
{
arg
.
value
-
1
};
Parameters
params
=
{
GetAddress
()};
for
(
int
i
=
0
;
i
<
2
;
++
i
)
{
m_children
.
push_back
(
GetFramework
().
CreateActor
<
testee
<
RefType
>>
(
params
));
m_children
.
back
().
Push
(
msg
,
GetAddress
());
}
}
}
void
result_handler
(
result
const
&
arg
,
const
Address
)
{
if
(
!
m_first_result_received
)
{
m_first_result_received
=
true
;
m_first_result
=
arg
.
value
;
}
else
{
Send
(
result
{
m_first_result
+
arg
.
value
});
m_children
.
clear
();
}
}
send_testee
(
Parameters
const
&
p
)
:
m_parent
(
p
.
arg0
),
m_first_result_received
(
false
)
{
RegisterHandler
(
this
,
&
send_testee
::
spread_handler
);
RegisterHandler
(
this
,
&
send_testee
::
result_handler
);
}
}
;
void
usage
()
{
cout
<<
"usage: theron_actor_creation _ POW"
<<
endl
<<
" creates 2^POW actors"
<<
endl
<<
endl
;
}
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
!=
3
)
{
usage
();
return
1
;
}
int
num
=
rd
<
int
>
(
argv
[
2
]);
Receiver
r
;
Framework
framework
;
ActorRef
aref
(
framework
.
CreateActor
<
testee
>
(
teste
::
Parameters
{
r
.
GetAddress
()}));
aref
.
Push
(
spread
{
num
},
r
.
GetAddress
());
r
.
Wait
();
}
benchmarks/theron_mailbox_performance.cpp
View file @
b33b7052
#define THERON_USE_BOOST_THREADS 1
#include <Theron/Framework.h>
#include <Theron/Actor.h>
#include <Theron/Framework.h>
#include <Theron/Actor.h>
#include <thread>
#include <cstdint>
#include <iostream>
#include <functional>
#include "utility.hpp"
using
std
::
cerr
;
using
std
::
cout
;
using
std
::
endl
;
...
...
@@ -17,89 +18,68 @@ using namespace Theron;
int64_t
t_max
=
0
;
// A trivial actor that does nothing.
struct
receiver
:
Actor
struct
receiver
:
Actor
{
int64_t
m_num
;
int64_t
m_num
;
void
handler
(
int64_t
const
&
,
Address
from
)
{
if
(
++
m_num
==
t_max
)
Send
(
t_max
,
from
);
}
void
handler
(
int64_t
const
&
,
const
Address
from
)
{
if
(
++
m_num
==
t_max
)
Send
(
t_max
,
from
);
}
//receiver(int64_t max, Address waiter) : m_max(max), m_num(0), m_waiter(waiter)
receiver
()
:
m_num
(
0
)
{
RegisterHandler
(
this
,
&
receiver
::
handler
);
}
{
RegisterHandler
(
this
,
&
receiver
::
handler
);
}
};
};
void
send_sender
(
Framework
&
f
,
ActorRef
ref
,
Address
waiter
,
int64_t
num
)
{
auto
addr
=
ref
.
GetAddress
();
int64_t
msg
;
for
(
int64_t
i
=
0
;
i
<
num
;
++
i
)
f
.
Send
(
msg
,
waiter
,
addr
);
//ref.Push(msg, ref.GetAddress());
int64_t
msg
;
for
(
int64_t
i
=
0
;
i
<
num
;
++
i
)
f
.
Send
(
msg
,
waiter
,
addr
);
}
void
push_sender
(
Framework
&
f
,
ActorRef
ref
,
Address
waiter
,
int64_t
num
)
{
int64_t
msg
;
for
(
int64_t
i
=
0
;
i
<
num
;
++
i
)
ref
.
Push
(
msg
,
waiter
);
}
template
<
typename
T
>
T
rd
(
char
const
*
cstr
)
{
char
*
endptr
=
nullptr
;
T
result
=
static_cast
<
T
>
(
strtol
(
cstr
,
&
endptr
,
10
));
if
(
endptr
==
nullptr
||
*
endptr
!=
'\0'
)
{
std
::
string
errstr
;
errstr
+=
"
\"
"
;
errstr
+=
cstr
;
errstr
+=
"
\"
is not an integer"
;
throw
std
::
invalid_argument
(
errstr
);
}
return
result
;
int64_t
msg
;
for
(
int64_t
i
=
0
;
i
<
num
;
++
i
)
ref
.
Push
(
msg
,
waiter
);
}
void
usage
()
{
cout
<<
"usage ('push'|'send') (num_threads) (num_messages)"
<<
endl
;
cout
<<
"usage ('push'|'send') (num_threads) (num_messages)"
<<
endl
;
exit
(
1
);
}
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
!=
4
)
{
return
1
;
}
if
(
argc
!=
4
)
{
return
1
;
}
enum
{
invalid_impl
,
push_impl
,
send_impl
}
impl
=
invalid_impl
;
if
(
strcmp
(
argv
[
1
],
"push"
)
==
0
)
impl
=
push_impl
;
else
if
(
strcmp
(
argv
[
1
],
"send"
)
==
0
)
impl
=
send_impl
;
else
usage
();
auto
num_sender
=
rd
<
int64_t
>
(
argv
[
2
]);
auto
num_msgs
=
rd
<
int64_t
>
(
argv
[
3
]);
Receiver
r
;
Receiver
r
;
t_max
=
num_sender
*
num_msgs
;
auto
receiverAddr
=
r
.
GetAddress
();
Framework
framework
;
ActorRef
aref
(
framework
.
CreateActor
<
receiver
>
());
Framework
framework
;
ActorRef
aref
(
framework
.
CreateActor
<
receiver
>
());
std
::
list
<
std
::
thread
>
threads
;
auto
impl_fun
=
(
impl
==
push_impl
)
?
send_sender
:
push_sender
;
for
(
int64_t
i
=
0
;
i
<
num_sender
;
++
i
)
for
(
int64_t
i
=
0
;
i
<
num_sender
;
++
i
)
{
threads
.
push_back
(
std
::
thread
(
impl_fun
,
std
::
ref
(
framework
),
aref
,
receiverAddr
,
num_msgs
));
}
r
.
Wait
();
r
.
Wait
();
for
(
auto
&
t
:
threads
)
t
.
join
();
return
0
;
}
return
0
;
}
benchmarks/utility.hpp
0 → 100644
View file @
b33b7052
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011, 2012 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation, either version 3 of the License *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#ifndef UTILITY_HPP
#define UTILITY_HPP
#include <stdexcept>
template
<
typename
T
>
T
rd
(
char
const
*
cstr
)
{
char
*
endptr
=
nullptr
;
T
result
=
static_cast
<
T
>
(
strtol
(
cstr
,
&
endptr
,
10
));
if
(
endptr
==
nullptr
||
*
endptr
!=
'\0'
)
{
std
::
string
errstr
;
errstr
+=
"
\"
"
;
errstr
+=
cstr
;
errstr
+=
"
\"
is not an integer"
;
throw
std
::
invalid_argument
(
errstr
);
}
return
result
;
}
#endif // UTILITY_HPP
cppa.files
View file @
b33b7052
...
...
@@ -254,3 +254,7 @@ cppa/any_tuple_view.hpp
cppa/match.hpp
benchmarks/Matching.scala
benchmarks/matching.cpp
benchmarks/matching.erl
benchmarks/theron_mailbox_performance.cpp
benchmarks/utility.hpp
benchmarks/theron_actor_creation.cpp
cppa/detail/matches.hpp
View file @
b33b7052
...
...
@@ -153,7 +153,6 @@ class is_pm_decorated
};
template
<
class
TupleIterator
,
class
PatternIterator
>
//int matches(TupleIterator targ, typename pattern<P...>::const_iterator iter)
auto
matches
(
TupleIterator
targ
,
PatternIterator
iter
)
->
typename
util
::
enable_if_c
<
is_pm_decorated
<
TupleIterator
>::
value
,
bool
>::
type
{
...
...
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