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
461f8757
Commit
461f8757
authored
Jan 06, 2012
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated actor creation benchmark
parent
c868d8c9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
89 additions
and
13 deletions
+89
-13
benchmarks/actor_creation.cpp
benchmarks/actor_creation.cpp
+58
-8
benchmarks/actor_creation.erl
benchmarks/actor_creation.erl
+31
-5
No files found.
benchmarks/actor_creation.cpp
View file @
461f8757
...
...
@@ -28,40 +28,80 @@
\******************************************************************************/
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include "cppa/cppa.hpp"
#include "cppa/fsm_actor.hpp"
using
std
::
cout
;
using
std
::
cerr
;
using
std
::
endl
;
using
std
::
uint32_t
;
using
namespace
cppa
;
struct
testee
:
event_based_actor
{
actor_ptr
m_parent
;
int
m_x
;
testee
(
int
x
)
:
m_x
(
x
)
testee
(
actor_ptr
const
&
parent
,
int
x
)
:
m_parent
(
parent
),
m_x
(
x
)
{
}
void
init
()
{
if
(
m_x
>
0
)
{
spawn
(
new
testee
(
m_x
-
1
));
spawn
(
new
testee
(
m_x
-
1
));
spawn
(
new
testee
(
this
,
m_x
-
1
));
spawn
(
new
testee
(
this
,
m_x
-
1
));
become
(
on
<
atom
(
"result"
),
uint32_t
>
()
>>
[
=
](
uint32_t
value1
)
{
become
(
on
<
atom
(
"result"
),
uint32_t
>
()
>>
[
=
](
uint32_t
value2
)
{
send
(
m_parent
,
atom
(
"result"
),
value1
+
value2
);
quit
(
exit_reason
::
normal
);
}
);
}
);
}
else
{
send
(
m_parent
,
atom
(
"result"
),
(
std
::
uint32_t
)
1
);
}
}
};
void
cr_stacked_actor
(
int
x
)
void
cr_stacked_actor
(
actor_ptr
parent
,
int
x
)
{
if
(
x
>
0
)
{
spawn
(
cr_stacked_actor
,
x
-
1
);
spawn
(
cr_stacked_actor
,
x
-
1
);
spawn
(
cr_stacked_actor
,
self
,
x
-
1
);
spawn
(
cr_stacked_actor
,
self
,
x
-
1
);
receive
(
on
<
atom
(
"result"
),
uint32_t
>
()
>>
[
&
](
uint32_t
value1
)
{
receive
(
on
<
atom
(
"result"
),
uint32_t
>
()
>>
[
&
](
uint32_t
value2
)
{
send
(
parent
,
atom
(
"result"
),
value1
+
value2
);
quit
(
exit_reason
::
normal
);
}
);
}
);
}
else
{
send
(
parent
,
atom
(
"result"
),
(
std
::
uint32_t
)
1
);
}
}
...
...
@@ -85,17 +125,27 @@ int main(int argc, char** argv)
}
if
(
strcmp
(
argv
[
1
],
"stacked"
)
==
0
)
{
spawn
(
cr_stacked_actor
,
num
);
spawn
(
cr_stacked_actor
,
self
,
num
);
}
else
if
(
strcmp
(
argv
[
1
],
"event-based"
)
==
0
)
{
spawn
(
new
testee
(
num
));
spawn
(
new
testee
(
self
,
num
));
}
else
{
usage
();
return
1
;
}
receive
(
on
<
atom
(
"result"
),
uint32_t
>
()
>>
[
=
](
uint32_t
value
)
{
//cout << "value = " << value << endl
// << "expected => 2^" << num << " = "
// << (1 << num) << endl;
assert
(
value
==
(((
uint32_t
)
1
)
<<
num
));
}
);
await_all_others_done
();
}
else
...
...
benchmarks/actor_creation.erl
View file @
461f8757
-
module
(
actor_creation
).
-
export
([
testee
/
1
]).
-
export
([
start
/
1
,
testee
/
2
]).
testee
(
N
)
->
if
N
>
0
->
spawn
(
actor_creation
,
testee
,
[
N
-
1
]),
spawn
(
actor_creation
,
testee
,
[
N
-
1
])
testee
(
Pid
,
0
)
->
Pid
!
{
result
,
1
};
testee
(
Pid
,
N
)
->
spawn
(
actor_creation
,
testee
,
[
self
(),
N
-
1
]),
spawn
(
actor_creation
,
testee
,
[
self
(),
N
-
1
]),
receive
{
result
,
X1
}
->
receive
{
result
,
X2
}
->
Pid
!
{
result
,
(
X1
+
X2
)}
end
end
.
start
(
X
)
->
[
H
|_]
=
X
,
N
=
list_to_integer
(
atom_to_list
(
H
)),
spawn
(
actor_creation
,
testee
,
[
self
(),
N
]),
spawn
(
actor_creation
,
testee
,
[
self
(),
N
]),
receive
{
result
,
X1
}
->
receive
{
result
,
X2
}
->
if
(
X1
+
X2
)
==
(
2
bsl
N
)
->
X1
+
X2
;
true
->
error
(
"unexpted result!"
)
end
end
end
.
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