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
3df7809a
Commit
3df7809a
authored
Jan 07, 2012
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
benchmark update
parent
9db05b73
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
25 deletions
+22
-25
benchmarks/MailboxPerformance.scala
benchmarks/MailboxPerformance.scala
+22
-25
No files found.
benchmarks/MailboxPerformance.scala
View file @
3df7809a
...
@@ -10,25 +10,24 @@ object global {
...
@@ -10,25 +10,24 @@ object global {
}
}
class
ThreadedReceiver
(
n
:
Long
)
extends
Actor
{
class
ThreadedReceiver
(
n
:
Long
)
extends
Actor
{
def
act
()
{
override
def
act
()
{
var
i
:
Long
=
0
var
i
:
Long
=
0
while
(
i
<
n
)
while
(
i
<
n
)
receive
{
receive
{
case
Msg
=>
i
+=
1
case
Msg
=>
i
+=
1
}
}
Console
println
"received "
+
i
+
" messages"
}
}
}
}
class
ThreadlessReceiver
(
n
:
Long
)
extends
Actor
{
class
ThreadlessReceiver
(
n
:
Long
)
extends
Actor
{
def
rcv
(
rest
:
Long
)
{
var
i
:
Long
=
0
override
def
act
()
{
react
{
react
{
case
Msg
=>
if
(
rest
>
0
)
rcv
(
rest
-
1
);
case
Msg
=>
i
+=
1
if
(
i
<
n
)
act
}
}
}
}
def
act
()
{
rcv
(
n
);
}
}
}
class
AkkaReceiver
(
n
:
Long
)
extends
akka
.
actor
.
Actor
{
class
AkkaReceiver
(
n
:
Long
)
extends
akka
.
actor
.
Actor
{
...
@@ -47,15 +46,6 @@ object MailboxPerformance {
...
@@ -47,15 +46,6 @@ object MailboxPerformance {
def
usage
()
{
def
usage
()
{
Console
println
"usage: (threaded|threadless|akka) (num_threads) (msgs_per_thread)"
Console
println
"usage: (threaded|threadless|akka) (num_threads) (msgs_per_thread)"
}
}
def
cr_threads
(
receiver
:
{
def
!
(
msg:Any
)
:
Unit
},
threads
:
Int
,
msgs
:
Int
)
{
for
(
i
<-
0
until
threads
)
(
new
java
.
lang
.
Thread
{
override
def
run
()
{
for
(
j
<-
0
until
msgs
)
receiver
!
Msg
}
}).
start
}
def
main
(
args
:
Array
[
String
])
=
{
def
main
(
args
:
Array
[
String
])
=
{
if
(
args
.
size
!=
3
)
{
if
(
args
.
size
!=
3
)
{
usage
usage
...
@@ -63,18 +53,25 @@ object MailboxPerformance {
...
@@ -63,18 +53,25 @@ object MailboxPerformance {
}
}
val
threads
=
args
(
1
).
toInt
val
threads
=
args
(
1
).
toInt
val
msgs
=
args
(
2
).
toInt
val
msgs
=
args
(
2
).
toInt
if
(
args
(
0
)
==
"threaded"
)
{
val
impl
=
List
(
"threaded"
,
"threadless"
,
"akka"
).
indexOf
(
args
(
0
))
cr_threads
((
new
ThreadedReceiver
(
threads
*
msgs
)).
start
,
threads
,
msgs
)
if
(
impl
==
-
1
)
{
usage
}
}
else
if
(
args
(
0
)
==
"threadless"
)
{
else
if
(
impl
<
2
)
{
cr_threads
((
new
ThreadlessReceiver
(
threads
*
msgs
)).
start
,
threads
,
msgs
)
val
rcvRef
=
if
(
impl
==
0
)
(
new
ThreadedReceiver
(
threads
*
msgs
)).
start
else
(
new
ThreadlessReceiver
(
threads
*
msgs
)).
start
for
(
i
<-
0
until
threads
)
(
new
java
.
lang
.
Thread
{
override
def
run
()
{
for
(
_
<-
0
until
msgs
)
rcvRef
!
Msg
}
}).
start
}
}
else
if
(
args
(
0
)
==
"akka"
)
{
else
{
val
a
=
actorOf
(
new
AkkaReceiver
(
threads
*
msgs
)).
start
val
rcvRef
=
actorOf
(
new
AkkaReceiver
(
threads
*
msgs
)).
start
// akka actors define operator! with implicit argument
for
(
i
<-
0
until
threads
)
cr_threads
(
new
AnyRef
{
def
!
(
what
:
Any
)
{
a
!
what
}
},
threads
,
msgs
)
(
new
java
.
lang
.
Thread
{
override
def
run
()
{
for
(
_
<-
0
until
msgs
)
rcvRef
!
Msg
}
}).
start
global
.
latch
.
await
global
.
latch
.
await
}
}
else
usage
}
}
}
}
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