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
968233e2
Commit
968233e2
authored
Apr 30, 2012
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
distributed benchmark
parent
0b1c3a8f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
35 deletions
+36
-35
benchmarks/PingPong.scala
benchmarks/PingPong.scala
+18
-24
benchmarks/distributed.erl
benchmarks/distributed.erl
+14
-7
benchmarks/mk_scala.sh
benchmarks/mk_scala.sh
+4
-4
No files found.
benchmarks/PingPong.scala
View file @
968233e2
import
scala.actors.Actor
import
scala.actors.Actor
import
scala.actors.Actor._
import
scala.actors.Actor._
import
akka.actor.Actor.actorOf
import
akka.actor.Actor.remote
import
Console.println
import
Console.println
case
object
KickOff
case
object
KickOff
...
@@ -14,41 +12,36 @@ object global {
...
@@ -14,41 +12,36 @@ object global {
class
PingActor
(
num
:
Int
,
pong
:
akka.actor.ActorRef
)
extends
akka
.
actor
.
Actor
{
class
PingActor
(
num
:
Int
,
pong
:
akka.actor.ActorRef
)
extends
akka
.
actor
.
Actor
{
def
receive
=
{
def
receive
=
{
case
Pong
(
value
)
if
value
==
num
=>
{
case
Pong
(
`num`
)
=>
{
//println("Received final pong")
//println("Received final pong")
global
.
latch
.
countDown
global
.
latch
.
countDown
self
.
exit
context
.
stop
(
self
)
}
case
Pong
(
value
:
Int
)
=>
{
//println("Received Pong(" + value + ")")
self
.
reply
(
Ping
(
value
))
}
case
KickOff
=>
{
pong
!
Ping
(
0
)
}
}
case
Pong
(
value
)
=>
sender
!
Ping
(
value
+
1
)
case
KickOff
=>
pong
!
Ping
(
0
)
}
}
}
}
class
PongActor
extends
akka
.
actor
.
Actor
{
class
PongActor
extends
akka
.
actor
.
Actor
{
def
receive
=
{
def
receive
=
{
case
Ping
(
value
:
Int
)
=>
{
case
Ping
(
value
)
=>
sender
!
Pong
(
value
)
//println("Received Ping(" + value + ")")
self
.
reply
(
Pong
(
value
+
1
))
}
}
}
}
}
object
pingApp
{
object
pingApp
{
def
main
(
args
:
Array
[
String
])
=
{
def
main
(
args
:
Array
[
String
])
=
{
if
(
args
.
size
!=
3
)
{
if
(
args
.
size
!=
3
)
{
println
(
"usage: pingApp (host) (port)"
)
println
(
"usage: pingApp (host) (port)
(num pings)
"
)
println
(
"
(connects to pong-service of (host) on given
port)"
)
println
(
"
connects to pong-service@(host):(
port)"
)
System
.
exit
(
1
)
System
.
exit
(
1
)
}
}
val
pong
=
remote
.
actorFor
(
"pong-service"
,
args
(
0
),
args
(
1
).
toInt
)
val
host
=
args
(
0
)
val
myPing
=
actorOf
(
new
PingActor
(
args
(
2
).
toInt
,
pong
)).
start
val
port
=
args
(
1
).
toInt
remote
.
start
(
"localhost"
,
64002
).
register
(
"ping-service"
,
myPing
)
val
numPings
=
args
(
2
).
toInt
myPing
!
KickOff
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
global
.
latch
.
await
remote
.
shutdown
remote
.
shutdown
System
.
exit
(
0
)
System
.
exit
(
0
)
...
@@ -59,11 +52,12 @@ object pongApp {
...
@@ -59,11 +52,12 @@ object pongApp {
def
main
(
args
:
Array
[
String
])
=
{
def
main
(
args
:
Array
[
String
])
=
{
if
(
args
.
size
!=
1
)
{
if
(
args
.
size
!=
1
)
{
println
(
"usage: pongApp (port)"
)
println
(
"usage: pongApp (port)"
)
println
(
"
(binds pong-service to given port)
"
)
println
(
"
binds pong-service to given port
"
)
System
.
exit
(
1
)
System
.
exit
(
1
)
}
}
val
myPong
=
actorOf
(
new
PongActor
).
start
remote
.
start
(
"localhost"
,
args
(
0
).
toInt
)
remote
.
start
(
"localhost"
,
args
(
0
).
toInt
)
.
register
(
"pong-service"
,
myPong
)
.
register
(
"pong-service"
,
actorOf
(
new
PongActor
).
start
)
}
}
}
}
benchmarks/distributed.erl
View file @
968233e2
...
@@ -7,24 +7,31 @@ ping_loop(Parent, Pong) ->
...
@@ -7,24 +7,31 @@ ping_loop(Parent, Pong) ->
{
pong
,
X
}
->
{
pong
,
X
}
->
Pong
!
{
ping
,
self
(),
X
-
1
},
Pong
!
{
ping
,
self
(),
X
-
1
},
ping_loop
(
Parent
,
Pong
);
ping_loop
(
Parent
,
Pong
);
{
kickoff
,
Value
}
->
{
kickoff
,
X
}
->
Pong
!
{
ping
,
self
(),
Value
},
Pong
!
{
ping
,
self
(),
X
},
ping_loop
(
Parent
,
Pong
)
ping_loop
(
Parent
,
Pong
)
end
.
end
.
server_loop
(
Pongs
)
->
server_loop
(
Pongs
)
->
receive
receive
{
ping
,
Pid
,
Value
}
->
Pid
!
{
pong
,
Value
},
server_loop
(
Pongs
);
{
ping
,
Pid
,
X
}
->
Pid
!
{
pong
,
X
},
server_loop
(
Pongs
);
{
add_pong
,
Pid
,
Node
}
->
{
add_pong
,
Pid
,
Node
}
->
case
lists
:
any
(
fun
({
N
,
_})
->
N
==
Node
end
,
Pongs
)
of
case
lists
:
any
(
fun
({
N
,
_})
->
N
==
Node
end
,
Pongs
)
of
true
->
true
->
Pid
!
{
ok
},
Pid
!
{
ok
,
cached
},
server_loop
(
Pongs
);
server_loop
(
Pongs
);
false
->
false
->
case
rpc
:
call
(
Node
,
erlang
,
whereis
,
[
pong
])
of
case
rpc
:
call
(
Node
,
erlang
,
whereis
,
[
pong
])
of
{
badrpc
,
Reason
}
->
Pid
!
{
error
,
Reason
};
{
badrpc
,
Reason
}
->
Pid
!
{
error
,
Reason
},
server_loop
(
Pongs
);
undefined
->
Pid
!
{
error
,
'pong is undefined'
},
server_loop
(
Pongs
);
Pong
->
Pong
->
Pid
!
{
ok
},
Pid
!
{
ok
,
added
},
server_loop
(
Pongs
++
[{
Node
,
Pong
}])
server_loop
(
Pongs
++
[{
Node
,
Pong
}])
end
end
end
;
end
;
...
@@ -43,7 +50,7 @@ add_pong_fun(Pong, Node, [Node|T]) -> add_pong_fun(Pong, Node, T);
...
@@ -43,7 +50,7 @@ add_pong_fun(Pong, Node, [Node|T]) -> add_pong_fun(Pong, Node, T);
add_pong_fun
(
Pong
,
Node
,
[
H
|
T
])
->
add_pong_fun
(
Pong
,
Node
,
[
H
|
T
])
->
Pong
!
{
add_pong
,
self
(),
H
},
Pong
!
{
add_pong
,
self
(),
H
},
receive
receive
{
ok
}
->
add_pong_fun
(
Pong
,
Node
,
T
);
{
ok
,
_
}
->
add_pong_fun
(
Pong
,
Node
,
T
);
{
error
,
Reason
}
->
error
(
Reason
)
{
error
,
Reason
}
->
error
(
Reason
)
after
10000
->
error
(
timeout
)
after
10000
->
error
(
timeout
)
end
.
end
.
...
...
benchmarks/mk_scala.sh
View file @
968233e2
#!/bin/bash
#!/bin/bash
if
[[
$#
-eq
0
]]
;
then
if
[[
$#
-eq
0
]]
;
then
for
i
in
*
.scala
;
do
for
i
in
*
.scala
;
do
echo
"
scalac -cp ../../akka-microkernel-1.2/lib/akka/akka-actor-1.2.jar
\"
$i
\"
"
echo
"
compile
\"
$i
\"
"
scalac
-cp
../../akka-microkernel-1.2/lib/akka/akka-actor-1.2.jar
"
$i
"
scalac
-cp
$AKKA_LIBS
"
$i
"
done
done
elif
[[
$#
-eq
1
]]
;
then
elif
[[
$#
-eq
1
]]
;
then
echo
"
scalac -cp ../../akka-microkernel-1.2/lib/akka/akka-actor-1.2.jar
\"
$1
.scala
\"
"
echo
"
compile
\"
$1
.scala
\"
"
scalac
-cp
../../akka-microkernel-1.2/lib/akka/akka-actor-1.2.jar
"
$1
.scala"
scalac
-cp
$AKKA_LIBS
"
$1
.scala"
fi
fi
echo
done
echo
done
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