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
75c91e37
Commit
75c91e37
authored
May 02, 2012
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
benchmark update
parent
e6d6a30b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
204 additions
and
68 deletions
+204
-68
benchmarks/Distributed.scala
benchmarks/Distributed.scala
+157
-0
benchmarks/PingPong.scala
benchmarks/PingPong.scala
+0
-63
benchmarks/application.conf
benchmarks/application.conf
+42
-0
benchmarks/distributed.cpp
benchmarks/distributed.cpp
+4
-4
cppa.files
cppa.files
+1
-1
No files found.
benchmarks/Distributed.scala
0 → 100644
View file @
75c91e37
import
akka.actor.
{
Props
,
Actor
,
ActorRef
,
ActorSystem
}
import
com.typesafe.config.ConfigFactory
import
Console.println
case
object
Done
case
class
Error
(
msg
:
String
)
case
class
KickOff
(
value
:
Int
)
case
class
Ping
(
value
:
Int
)
case
class
Pong
(
value
:
Int
)
case
class
AddPong
(
path
:
String
)
case
object
Hello
case
object
Olleh
case
class
RunClient
(
pongs
:
List
[
ActorRef
],
numPings
:
Int
)
object
global
{
val
latch
=
new
java
.
util
.
concurrent
.
CountDownLatch
(
1
)
}
class
PingActor
(
parent
:
ActorRef
,
pong
:
ActorRef
)
extends
Actor
{
def
receive
=
{
case
Pong
(
0
)
=>
{
//println(parent + " ! Done")
parent
!
Done
context
.
stop
(
self
)
}
case
Pong
(
value
)
=>
{
sender
!
Ping
(
value
-
1
)
}
case
KickOff
(
value
)
=>
{
//println("PingActor::KickOff " + value)
pong
!
Ping
(
value
)
}
}
}
class
ServerActor
(
system
:
ActorSystem
)
extends
Actor
{
var
pongs
=
List
[
ActorRef
]()
def
receive
=
{
case
Ping
(
value
)
=>
{
sender
!
Pong
(
value
)
}
case
AddPong
(
path
)
=>
{
//println("add actor " + path)
if
(
pongs
.
exists
((
x
)
=>
x
.
path
==
path
))
{
sender
!
Ok
}
else
{
val
pong
=
system
.
actorFor
(
path
)
pong
!
Hello
pongs
=
pong
::
pongs
sender
!
Ok
}
}
case
KickOff
(
value
)
=>
{
val
client
=
sender
//println("KickOff(" + value + ") from " + client)
pongs
.
foreach
((
x
)
=>
context
.
actorOf
(
Props
(
new
PingActor
(
client
,
x
)))
!
KickOff
(
value
))
}
case
Hello
=>
{
sender
!
Olleh
}
case
Olleh
=>
{
//println("Olleh from " + sender)
}
}
}
class
ClientActor
extends
Actor
{
import
context._
var
left
:
Int
=
0
def
collectDoneMessages
:
Receive
=
{
case
Done
=>
{
//println("Done")
if
(
left
==
1
)
{
global
.
latch
.
countDown
context
.
stop
(
self
)
}
else
{
left
=
left
-
1
}
}
case
x
=>
{
// ignore any other message
}
}
def
collectOkMessages
(
pongs
:
List
[
ActorRef
],
numPings
:
Int
)
:
Receive
=
{
case
Ok
=>
{
//println("Ok")
if
(
left
==
1
)
{
left
=
pongs
.
length
*
(
pongs
.
length
-
1
)
pongs
.
foreach
(
x
=>
x
!
KickOff
(
numPings
))
become
(
collectDoneMessages
)
}
else
{
left
=
left
-
1
}
}
}
def
receive
=
{
case
RunClient
(
pongs
,
numPings
)
=>
{
pongs
.
foreach
(
x
=>
pongs
.
foreach
(
y
=>
if
(
x
!=
y
)
{
x
!
AddPong
(
y
.
path
.
toString
)
}))
left
=
pongs
.
length
*
(
pongs
.
length
-
1
)
become
(
collectOkMessages
(
pongs
,
numPings
))
}
}
}
object
distributedClientApp
{
def
main
(
args
:
Array
[
String
])
=
{
val
system
=
ActorSystem
(
"benchmark"
,
ConfigFactory
.
load
.
getConfig
(
"benchmark"
))
var
numPings
:
Int
=
0
var
pongs
=
List
[
ActorRef
]()
val
NumPings
=
"num_pings=([0-9]+)"
.
r
args
.
foreach
(
arg
=>
arg
match
{
case
NumPings
(
num
)
=>
{
numPings
=
num
.
toInt
}
case
_
=>
{
//println("add actor " + arg)
pongs
=
system
.
actorFor
(
arg
)
::
pongs
}
})
system
.
actorOf
(
Props
[
ClientActor
])
!
RunClient
(
pongs
,
numPings
)
global
.
latch
.
await
System
.
exit
(
0
)
}
}
object
distributedServerApp
{
def
main
(
args
:
Array
[
String
])
=
{
val
sysName
=
if
(
args
.
length
>
0
)
args
(
0
)
else
"pongServer"
val
system
=
ActorSystem
(
sysName
,
ConfigFactory
.
load
.
getConfig
(
"pongServer"
))
val
pong
=
system
.
actorOf
(
Props
(
new
ServerActor
(
system
)),
"pong"
)
//val subSystem = ActorSystem(sysName + "Client", ConfigFactory.load.getConfig("benchmark"))
//val pong = system.actorOf(Props(new ServerActor(subSystem)), "pong")
}
}
benchmarks/PingPong.scala
deleted
100644 → 0
View file @
e6d6a30b
import
scala.actors.Actor
import
scala.actors.Actor._
import
Console.println
case
object
KickOff
case
class
Ping
(
value
:
Int
)
case
class
Pong
(
value
:
Int
)
object
global
{
val
latch
=
new
java
.
util
.
concurrent
.
CountDownLatch
(
1
)
}
class
PingActor
(
num
:
Int
,
pong
:
akka.actor.ActorRef
)
extends
akka
.
actor
.
Actor
{
def
receive
=
{
case
Pong
(
`num`
)
=>
{
//println("Received final pong")
global
.
latch
.
countDown
context
.
stop
(
self
)
}
case
Pong
(
value
)
=>
sender
!
Ping
(
value
+
1
)
case
KickOff
=>
pong
!
Ping
(
0
)
}
}
class
PongActor
extends
akka
.
actor
.
Actor
{
def
receive
=
{
case
Ping
(
value
)
=>
sender
!
Pong
(
value
)
}
}
object
pingApp
{
def
main
(
args
:
Array
[
String
])
=
{
if
(
args
.
size
!=
3
)
{
println
(
"usage: pingApp (host) (port) (num pings)"
)
println
(
" connects to pong-service@(host):(port)"
)
System
.
exit
(
1
)
}
val
host
=
args
(
0
)
val
port
=
args
(
1
).
toInt
val
numPings
=
args
(
2
).
toInt
val
pong
=
remote
.
actorFor
(
"pong-service"
,
host
,
port
)
val
ping
=
system
.
actorOf
(
Props
(
new
PingActor
(
numPings
,
pong
)),
name
=
"ping"
)
remote
.
start
(
"localhost"
,
64002
).
register
(
"ping-service"
,
ping
)
ping
!
KickOff
global
.
latch
.
await
remote
.
shutdown
System
.
exit
(
0
)
}
}
object
pongApp
{
def
main
(
args
:
Array
[
String
])
=
{
if
(
args
.
size
!=
1
)
{
println
(
"usage: pongApp (port)"
)
println
(
" binds pong-service to given port"
)
System
.
exit
(
1
)
}
remote
.
start
(
"localhost"
,
args
(
0
).
toInt
)
.
register
(
"pong-service"
,
actorOf
(
new
PongActor
).
start
)
}
}
benchmarks/application.conf
0 → 100644
View file @
75c91e37
#benchmark {
# include "common"
#
# akka {
# loglevel = ERROR
# remote {
# netty.port = 0
# untrusted-mode = on
# transport = "akka.remote.netty.NettyRemoteTransport"
# }
# }
#}
benchmark
{
akka
{
loglevel
=
ERROR
actor
{
provider
=
"akka.remote.RemoteActorRefProvider"
}
remote
{
netty
{
hostname
=
"127.0.0.1"
port
=
0
}
}
}
}
pongServer
{
akka
{
loglevel
=
ERROR
actor
{
provider
=
"akka.remote.RemoteActorRefProvider"
}
remote
{
netty
{
hostname
=
"127.0.0.1"
port
=
4422
}
}
}
}
benchmarks/distributed.cpp
View file @
75c91e37
...
...
@@ -76,15 +76,15 @@ inline option<int> _2i(std::string const& str)
void
usage
()
{
cout
<<
"Running in server mode:"
<<
endl
<<
" mode=server "
<<
endl
<<
" mode=server "
<<
endl
<<
" --port=NUM publishes an actor at port NUM"
<<
endl
<<
" -p NUM alias for --port=NUM"
<<
endl
<<
endl
<<
endl
<<
"Running the benchmark:"
<<
endl
<<
" mode=benchmark run the benchmark, connect to any number"
<<
endl
<<
" mode=benchmark run the benchmark, connect to any number"
<<
endl
<<
" of given servers, use HOST:PORT syntax"
<<
endl
<<
" num_pings=NUM run benchmark with NUM messages per node"
<<
endl
<<
" num_pings=NUM run benchmark with NUM messages per node"
<<
endl
<<
endl
<<
" example: mode=benchmark 192.168.9.1:1234 "
"192.168.9.2:1234 "
...
...
@@ -92,7 +92,7 @@ void usage()
<<
endl
<<
endl
<<
"Shutdown servers:"
<<
endl
<<
" mode=shutdown shuts down any number of given servers"
<<
endl
<<
" mode=shutdown shuts down any number of given servers"
<<
endl
<<
endl
<<
endl
<<
"Miscellaneous:"
<<
endl
...
...
cppa.files
View file @
75c91e37
benchmarks/ActorCreation.scala
benchmarks/Distributed.scala
benchmarks/MailboxPerformance.scala
benchmarks/Matching.scala
benchmarks/MixedCase.scala
benchmarks/PingPong.scala
benchmarks/actor_creation.cpp
benchmarks/actor_creation.erl
benchmarks/distributed.cpp
...
...
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