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
783b2413
Commit
783b2413
authored
Aug 31, 2012
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
placed all scala benchmarks to package org.libcppa.{bench name} and provide a 'Main' class
parent
0575700f
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
292 additions
and
172 deletions
+292
-172
benchmarks/scala/ActorCreation.scala
benchmarks/scala/ActorCreation.scala
+45
-30
benchmarks/scala/Distributed.scala
benchmarks/scala/Distributed.scala
+45
-27
benchmarks/scala/MailboxPerformance.scala
benchmarks/scala/MailboxPerformance.scala
+39
-30
benchmarks/scala/Makefile
benchmarks/scala/Makefile
+31
-8
benchmarks/scala/Matching.scala
benchmarks/scala/Matching.scala
+48
-42
benchmarks/scala/MixedCase.scala
benchmarks/scala/MixedCase.scala
+48
-33
benchmarks/scala/Utility.scala
benchmarks/scala/Utility.scala
+21
-0
benchmarks/scala_test.sh
benchmarks/scala_test.sh
+14
-2
cppa.files
cppa.files
+1
-0
No files found.
benchmarks/scala/ActorCreation.scala
View file @
783b2413
package
org.libcppa.actor_creation
import
org.libcppa.utility.IntStr
import
scala.actors.Actor
import
scala.actors.Actor._
import
akka.actor.
{
Props
,
Actor
=>
AkkaActor
,
ActorRef
=>
AkkaActorRef
,
ActorSystem
}
...
...
@@ -91,44 +95,55 @@ class AkkaRootTestee(n: Int) extends AkkaActor {
}
}
object
ActorCreation
{
def
usage
()
{
Console
println
"usage: (threaded|threadless|akka) POW\n creates 2^POW actors of given impl"
}
def
main
(
args
:
Array
[
String
])
:
Unit
=
{
if
(
args
.
size
!=
2
)
{
usage
throw
new
IllegalArgumentException
(
""
)
class
ActorCreation
(
n
:
Int
)
{
def
runThreaded
()
{
val
newMax
=
(
1
<<
n
)
+
100
System
.
setProperty
(
"actors.maxPoolSize"
,
newMax
.
toString
)
(
new
ThreadedTestee
(
self
)).
start
!
Spread
(
n
)
receive
{
case
Result
(
v
)
=>
if
(
v
!=
(
1
<<
n
))
Console
.
println
(
"ERROR: expected "
+
(
1
<<
n
)
+
", received "
+
v
)
}
val
n
=
args
(
1
).
toInt
if
(
args
(
0
)
==
"threaded"
)
{
val
newMax
=
(
1
<<
n
)
+
100
System
.
setProperty
(
"actors.maxPoolSize"
,
newMax
.
toString
)
(
new
Thread
ed
Testee
(
self
)).
start
!
Spread
(
n
)
re
ceive
{
}
def
runThreadless
()
{
actor
{
(
new
Thread
less
Testee
(
self
)).
start
!
Spread
(
n
)
re
act
{
case
Result
(
v
)
=>
if
(
v
!=
(
1
<<
n
))
Console
.
println
(
"ERROR: expected "
+
(
1
<<
n
)
+
", received "
+
v
)
}
}
else
if
(
args
(
0
)
==
"threadless"
)
{
actor
{
(
new
ThreadlessTestee
(
self
)).
start
!
Spread
(
n
)
react
{
case
Result
(
v
)
=>
if
(
v
!=
(
1
<<
n
))
Console
.
println
(
"ERROR: expected "
+
(
1
<<
n
)
+
", received "
+
v
)
}
}
def
runAkka
()
{
val
system
=
ActorSystem
()
system
.
actorOf
(
Props
(
new
AkkaRootTestee
(
n
)))
!
GoAhead
global
.
latch
.
await
system
.
shutdown
System
.
exit
(
0
)
}
}
object
Main
{
def
usage
()
{
Console
println
"usage: (threaded|threadless|akka) POW\n creates 2^POW actors of given impl"
}
def
main
(
args
:
Array
[
String
])
:
Unit
=
args
match
{
case
Array
(
impl
,
IntStr
(
n
))
=>
{
val
prog
=
new
ActorCreation
(
n
)
impl
match
{
case
"threaded"
=>
prog
.
runThreaded
case
"threadless"
=>
prog
.
runThreadless
case
"akka"
=>
prog
.
runAkka
case
_
=>
usage
}
}
else
if
(
args
(
0
)
==
"akka"
)
{
val
system
=
ActorSystem
()
system
.
actorOf
(
Props
(
new
AkkaRootTestee
(
n
)))
!
GoAhead
global
.
latch
.
await
system
.
shutdown
System
.
exit
(
0
)
}
else
usage
case
_
=>
usage
}
}
benchmarks/scala/Distributed.scala
View file @
783b2413
package
org.libcppa.distributed
import
org.libcppa.utility._
import
scala.actors._
import
scala.actors.Actor.self
import
scala.actors.remote.RemoteActor
...
...
@@ -313,12 +317,24 @@ class AkkaClientActor(system: ActorSystem) extends AkkaActor {
}
}
object
Distributed
{
class
Distributed
{
@tailrec
def
run
(
args
:
List
[
String
],
paths
:
List
[
String
],
numPings
:
Option
[
Int
],
finalizer
:
(
List
[
String
],
Int
)
=>
Unit
)
:
Unit
=
args
match
{
case
NumPings
(
num
)
::
tail
=>
numPings
match
{
def
runServer
(
port
:
Int
)
{
(
new
ServerActor
(
port
)).
start
}
def
runAkkaServer
()
{
val
system
=
ActorSystem
(
"pongServer"
,
ConfigFactory
.
load
.
getConfig
(
"pongServer"
))
system
.
actorOf
(
Props
(
new
AkkaServerActor
(
system
)),
"pong"
)
}
//private val NumPings = "num_pings=([0-9]+)".r
private
val
SimpleUri
=
"([0-9a-zA-Z\\.]+):([0-9]+)"
.
r
@tailrec
private
def
run
(
args
:
List
[
String
],
paths
:
List
[
String
],
numPings
:
Option
[
Int
],
finalizer
:
(
List
[
String
],
Int
)
=>
Unit
)
:
Unit
=
args
match
{
case
KeyValuePair
(
"num_pings"
,
IntStr
(
num
))
::
tail
=>
numPings
match
{
case
Some
(
x
)
=>
throw
new
IllegalArgumentException
(
"\"num_pings\" already defined, first value = "
+
x
+
", second value = "
+
num
)
case
None
=>
run
(
tail
,
paths
,
Some
(
num
.
toInt
),
finalizer
)
case
None
=>
run
(
tail
,
paths
,
Some
(
num
),
finalizer
)
}
case
arg
::
tail
=>
run
(
tail
,
arg
::
paths
,
numPings
,
finalizer
)
case
Nil
=>
numPings
match
{
...
...
@@ -330,33 +346,35 @@ object Distributed {
}
}
val
IntStr
=
"([0-9]+)"
.
r
val
NumPings
=
"num_pings=([0-9]+)"
.
r
val
SimpleUri
=
"([0-9a-zA-Z\\.]+):([0-9]+)"
.
r
def
runBenchmark
(
args
:
List
[
String
])
{
run
(
args
,
Nil
,
None
,
((
paths
,
x
)
=>
{
(
new
ClientActor
(
paths
map
(
path
=>
path
match
{
case
SimpleUri
(
host
,
port
)
=>
RemoteActorPath
(
path
,
host
,
port
.
toInt
)
}),
x
)).
start
}))
}
def
runAkkaBenchmark
(
args
:
List
[
String
])
{
run
(
args
,
Nil
,
None
,
((
paths
,
x
)
=>
{
val
system
=
ActorSystem
(
"benchmark"
,
ConfigFactory
.
load
.
getConfig
(
"benchmark"
))
system
.
actorOf
(
Props
(
new
AkkaClientActor
(
system
)))
!
RunAkkaClient
(
paths
,
x
)
global
.
latch
.
await
system
.
shutdown
System
.
exit
(
0
)
}))
}
}
object
Main
{
val
prog
=
new
Distributed
def
main
(
args
:
Array
[
String
])
:
Unit
=
args
match
{
// server mode
case
Array
(
"mode=server"
,
"remote_actors"
,
IntStr
(
istr
))
=>
(
new
ServerActor
(
istr
.
toInt
)).
start
case
Array
(
"mode=server"
,
"akka"
)
=>
{
val
system
=
ActorSystem
(
"pongServer"
,
ConfigFactory
.
load
.
getConfig
(
"pongServer"
))
val
pong
=
system
.
actorOf
(
Props
(
new
AkkaServerActor
(
system
)),
"pong"
)
Unit
}
case
Array
(
"mode=server"
,
"remote_actors"
,
IntStr
(
port
))
=>
prog
.
runServer
(
port
)
case
Array
(
"mode=server"
,
"akka"
)
=>
prog
.
runAkkaServer
// client mode
case
Array
(
"mode=benchmark"
,
"remote_actors"
,
_
*)
=>
{
run
(
args
.
toList
.
drop
(
2
),
Nil
,
None
,
((
paths
,
x
)
=>
{
(
new
ClientActor
(
paths
map
(
path
=>
path
match
{
case
SimpleUri
(
host
,
port
)
=>
RemoteActorPath
(
path
,
host
,
port
.
toInt
)
}),
x
)).
start
}))
}
case
Array
(
"mode=benchmark"
,
"akka"
,
_
*)
=>
{
run
(
args
.
toList
.
drop
(
2
),
Nil
,
None
,
((
paths
,
x
)
=>
{
val
system
=
ActorSystem
(
"benchmark"
,
ConfigFactory
.
load
.
getConfig
(
"benchmark"
))
system
.
actorOf
(
Props
(
new
AkkaClientActor
(
system
)))
!
RunAkkaClient
(
paths
,
x
)
global
.
latch
.
await
system
.
shutdown
System
.
exit
(
0
)
}))
}
case
Array
(
"mode=benchmark"
,
"remote_actors"
,
_
*)
=>
prog
.
runBenchmark
(
args
.
toList
.
drop
(
2
))
case
Array
(
"mode=benchmark"
,
"akka"
,
_
*)
=>
prog
.
runAkkaBenchmark
(
args
.
toList
.
drop
(
2
))
// error
case
_
=>
{
println
(
"Running in server mode:\n"
+
...
...
benchmarks/scala/MailboxPerformance.scala
View file @
783b2413
package
org.libcppa.mailbox_performance
import
org.libcppa.utility._
import
scala.actors.Actor
import
scala.actors.Actor._
import
akka.actor.
{
Props
,
Actor
=>
AkkaActor
,
ActorRef
=>
AkkaActorRef
,
ActorSystem
}
...
...
@@ -42,39 +46,44 @@ class AkkaReceiver(n: Long) extends akka.actor.Actor {
}
}
object
MailboxPerformance
{
class
MailboxPerformance
(
threads
:
Int
,
msgs
:
Int
)
{
val
total
=
threads
*
msgs
;
def
run
[
T
](
testee
:
T
,
fun
:
T
=>
Unit
)
{
for
(
_
<-
0
until
threads
)
{
(
new
Thread
{
override
def
run
()
{
for
(
_
<-
0
until
msgs
)
fun
(
testee
)
}
}).
start
}
}
def
runThreaded
()
{
run
((
new
ThreadedReceiver
(
total
)).
start
,
{(
a
:
Actor
)
=>
a
!
Msg
})
}
def
runThreadless
()
{
run
((
new
ThreadlessReceiver
(
total
)).
start
,
{(
a
:
Actor
)
=>
a
!
Msg
})
}
def
runAkka
()
{
val
system
=
ActorSystem
()
run
(
system
.
actorOf
(
Props
(
new
AkkaReceiver
(
total
))),
{(
a
:
AkkaActorRef
)
=>
a
!
Msg
})
global
.
latch
.
await
system
.
shutdown
System
.
exit
(
0
)
}
}
object
Main
{
def
usage
()
{
Console
println
"usage: (threaded|threadless|akka) (num_threads) (msgs_per_thread)"
}
def
main
(
args
:
Array
[
String
])
=
{
if
(
args
.
size
!=
3
)
{
usage
throw
new
IllegalArgumentException
(
""
)
}
val
threads
=
args
(
1
).
toInt
val
msgs
=
args
(
2
).
toInt
val
impl
=
List
(
"threaded"
,
"threadless"
,
"akka"
).
indexOf
(
args
(
0
))
if
(
impl
==
-
1
)
{
usage
}
else
if
(
impl
<
2
)
{
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
{
val
system
=
ActorSystem
()
val
rcvRef
=
system
.
actorOf
(
Props
(
new
AkkaReceiver
(
threads
*
msgs
)))
for
(
i
<-
0
until
threads
)
(
new
java
.
lang
.
Thread
{
override
def
run
()
{
for
(
_
<-
0
until
msgs
)
rcvRef
!
Msg
}
}).
start
global
.
latch
.
await
system
.
shutdown
System
.
exit
(
0
)
def
main
(
args
:
Array
[
String
])
:
Unit
=
args
match
{
case
Array
(
impl
,
IntStr
(
threads
),
IntStr
(
msgs
))
=>
{
val
prog
=
new
MailboxPerformance
(
threads
,
msgs
)
impl
match
{
case
"threaded"
=>
prog
.
runThreaded
case
"threadless"
=>
prog
.
runThreadless
case
"akka"
=>
prog
.
runAkka
case
_
=>
usage
}
}
case
_
=>
usage
}
}
benchmarks/scala/Makefile
View file @
783b2413
C
C
=
scalac
LIBPATH
=
/home/neverlord/akka-2.0.
1
/lib/akka
SCALA
C
=
scalac
LIBPATH
=
/home/neverlord/akka-2.0.
3
/lib/akka
CLASSPATH
=
$(
shell
for
i
in
$(LIBPATH)
/
*
.jar
;
do
printf
%s
$$
i:
;
done
)
#CLASSPATH=$(LIBPATH)/akka-kernel-2.0.3.jar:$(LIBPATH)/akka-actor-2.0.3.jar
FLAGS
=
-cp
$(CLASSPATH)
FILES
=
ActorCreation.scala Distributed.scala MailboxPerformance.scala MixedCase.scala Matching.scala
CLASS
ES
=
$(FILES:.scala=.class)
#
FILES=ActorCreation.scala Distributed.scala MailboxPerformance.scala MixedCase.scala Matching.scala
#CLASS_FIL
ES=$(FILES:.scala=.class)
%.class
:
%
.scala
$(CC)
$(FLAGS)
$<
FILES
=
ActorCreation.scala Distributed.scala MailboxPerformance.scala Matching.scala MixedCase
.scala
CLASS_FILES
=
$(
foreach
FILE,
$(FILES)
,org/libcppa/
$(
shell
echo
$(FILE:.scala=)
|
sed
's/\(.\)\([A-Z]\)/\1_\2/g'
|
tr
[
:upper:]
[
:lower:]
)
/
$(FILE:.scala=.class)
)
all
:
$(CLASSES)
UTILITY
=
org/libcppa/utility/Utility.class
all
:
$(CLASS_FILES)
org/libcppa/utility/Utility.class
:
Utility.scala
$(SCALAC)
$(FLAGS)
Utility.scala
#$(CLASS_FILES): $(FILES) org/libcppa/utility/Utility.class
org/libcppa/actor_creation/ActorCreation.class
:
ActorCreation.scala $(UTILITY)
$(SCALAC)
$(FLAGS)
$<
org/libcppa/distributed/Distributed.class
:
Distributed.scala $(UTILITY)
$(SCALAC)
$(FLAGS)
$<
org/libcppa/mailbox_performance/MailboxPerformance.class
:
MailboxPerformance.scala $(UTILITY)
$(SCALAC)
$(FLAGS)
$<
org/libcppa/matching/Matching.class
:
Matching.scala $(UTILITY)
$(SCALAC)
$(FLAGS)
$<
org/libcppa/mixed_case/MixedCase.class
:
MixedCase.scala $(UTILITY)
$(SCALAC)
$(FLAGS)
$<
clean
:
rm
-
f
*
.class
rm
-
rf
org/
.PHONY
:
all clean
benchmarks/scala/Matching.scala
View file @
783b2413
package
org.libcppa.matching
import
org.libcppa.utility._
import
Console.println
import
scala.
{
PartialFunction
=>
PF
}
...
...
@@ -9,47 +13,49 @@ case class Msg5(val0: Int, val1: Int, val2: Int)
case
class
Msg6
(
val0
:
Int
,
val1
:
Double
,
val2
:
String
)
object
Matching
{
def
main
(
args
:
Array
[
String
])
=
{
if
(
args
.
size
!=
1
)
{
println
(
"usage: Matching {NUM_LOOPS}"
)
System
.
exit
(
1
)
}
val
zero
:
Long
=
0
val
numLoops
=
args
(
0
).
toLong
var
msg1Matched
:
Long
=
0
;
var
msg2Matched
:
Long
=
0
;
var
msg3Matched
:
Long
=
0
;
var
msg4Matched
:
Long
=
0
;
var
msg5Matched
:
Long
=
0
;
var
msg6Matched
:
Long
=
0
;
val
partFun
:
PF
[
Any
,
Unit
]
=
{
case
Msg1
(
0
)
=>
msg1Matched
+=
1
case
Msg2
(
0.0
)
=>
msg2Matched
+=
1
case
Msg3
(
List
(
0
))
=>
msg3Matched
+=
1
case
Msg4
(
0
,
"0"
)
=>
msg4Matched
+=
1
case
Msg5
(
0
,
0
,
0
)
=>
msg5Matched
+=
1
case
Msg6
(
0
,
0.0
,
"0"
)
=>
msg6Matched
+=
1
}
val
m1
:
Any
=
Msg1
(
0
)
val
m2
:
Any
=
Msg2
(
0.0
)
val
m3
:
Any
=
Msg3
(
List
(
0
))
val
m4
:
Any
=
Msg4
(
0
,
"0"
)
val
m5
:
Any
=
Msg5
(
0
,
0
,
0
)
val
m6
:
Any
=
Msg6
(
0
,
0.0
,
"0"
)
for
(
_
<-
zero
until
numLoops
)
{
partFun
(
m1
)
partFun
(
m2
)
partFun
(
m3
)
partFun
(
m4
)
partFun
(
m5
)
partFun
(
m6
)
}
assert
(
msg1Matched
==
numLoops
)
assert
(
msg2Matched
==
numLoops
)
assert
(
msg3Matched
==
numLoops
)
assert
(
msg4Matched
==
numLoops
)
assert
(
msg5Matched
==
numLoops
)
assert
(
msg6Matched
==
numLoops
)
println
(
"msg1Matched = "
+
msg1Matched
.
toString
)
def
apply
(
numLoops
:
Long
)
{
val
zero
:
Long
=
0
var
msg1Matched
:
Long
=
0
;
var
msg2Matched
:
Long
=
0
;
var
msg3Matched
:
Long
=
0
;
var
msg4Matched
:
Long
=
0
;
var
msg5Matched
:
Long
=
0
;
var
msg6Matched
:
Long
=
0
;
val
partFun
:
PF
[
Any
,
Unit
]
=
{
case
Msg1
(
0
)
=>
msg1Matched
+=
1
case
Msg2
(
0.0
)
=>
msg2Matched
+=
1
case
Msg3
(
List
(
0
))
=>
msg3Matched
+=
1
case
Msg4
(
0
,
"0"
)
=>
msg4Matched
+=
1
case
Msg5
(
0
,
0
,
0
)
=>
msg5Matched
+=
1
case
Msg6
(
0
,
0.0
,
"0"
)
=>
msg6Matched
+=
1
}
val
m1
:
Any
=
Msg1
(
0
)
val
m2
:
Any
=
Msg2
(
0.0
)
val
m3
:
Any
=
Msg3
(
List
(
0
))
val
m4
:
Any
=
Msg4
(
0
,
"0"
)
val
m5
:
Any
=
Msg5
(
0
,
0
,
0
)
val
m6
:
Any
=
Msg6
(
0
,
0.0
,
"0"
)
for
(
_
<-
zero
until
numLoops
)
{
partFun
(
m1
)
partFun
(
m2
)
partFun
(
m3
)
partFun
(
m4
)
partFun
(
m5
)
partFun
(
m6
)
}
assert
(
msg1Matched
==
numLoops
)
assert
(
msg2Matched
==
numLoops
)
assert
(
msg3Matched
==
numLoops
)
assert
(
msg4Matched
==
numLoops
)
assert
(
msg5Matched
==
numLoops
)
assert
(
msg6Matched
==
numLoops
)
println
(
"msg1Matched = "
+
msg1Matched
.
toString
)
}
}
object
Main
{
def
main
(
args
:
Array
[
String
])
=
args
match
{
case
Array
(
IntStr
(
numLoops
))
=>
Matching
(
numLoops
)
case
_
=>
println
(
"usage: Matching {NUM_LOOPS}"
)
}
}
benchmarks/scala/MixedCase.scala
View file @
783b2413
package
org.libcppa.mixed_case
import
org.libcppa.utility.IntStr
import
scala.actors.Actor
import
scala.actors.Actor._
import
akka.actor.
{
Props
,
Actor
=>
AkkaActor
,
ActorRef
=>
AkkaActorRef
,
ActorSystem
}
...
...
@@ -211,41 +215,52 @@ class AkkaSupervisor(numMessages: Int) extends akka.actor.Actor {
}
}
object
MixedCase
{
def
usage
()
:
Nothing
=
{
class
MixedCase
(
numRings
:
Int
,
ringSize
:
Int
,
initToken
:
Int
,
reps
:
Int
)
{
final
val
numMessages
=
numRings
+
(
numRings
*
reps
)
final
val
initMsg
=
Init
(
ringSize
,
initToken
,
reps
)
def
runThreaded
()
{
val
s
=
(
new
ThreadedSupervisor
(
numMessages
)).
start
for
(
_
<-
0
until
numRings
)
(
new
ThreadedChainMaster
(
s
)).
start
!
initMsg
}
def
runThreadless
()
{
val
s
=
(
new
ThreadlessSupervisor
(
numMessages
)).
start
for
(
_
<-
0
until
numRings
)
(
new
ThreadlessChainMaster
(
s
)).
start
!
initMsg
}
def
runAkka
()
{
val
system
=
ActorSystem
();
val
s
=
system
.
actorOf
(
Props
(
new
AkkaSupervisor
(
numMessages
)))
for
(
_
<-
0
until
numRings
)
system
.
actorOf
(
Props
(
new
AkkaChainMaster
(
s
)))
!
initMsg
import
System.out.println
println
(
"awaiting latch"
)
global
.
latch
.
await
println
(
"shutdown akka system"
)
system
.
shutdown
println
(
"exit"
);
System
.
exit
(
0
)
}
}
object
Main
{
def
usage
()
=
{
Console
println
"usage: ('threaded'|'threadless'|'akka') (num rings) (ring size) (initial token value) (repetitions)"
System
.
exit
(
1
)
// why doesn't exit return Nothing?
throw
new
RuntimeException
(
""
)
}
def
main
(
args
:
Array
[
String
])
:
Unit
=
{
if
(
args
.
size
!=
5
)
usage
val
numRings
=
args
(
1
).
toInt
val
ringSize
=
args
(
2
).
toInt
val
initialTokenValue
=
args
(
3
).
toInt
val
repetitions
=
args
(
4
).
toInt
val
initMsg
=
Init
(
ringSize
,
initialTokenValue
,
repetitions
)
val
numMessages
=
(
numRings
+
(
numRings
*
repetitions
))
val
impl
=
args
(
0
)
if
(
impl
==
"threaded"
)
{
//System.setProperty("actors.maxPoolSize", (numRings + (numRings * ringSize) + 10).toString)
val
s
=
(
new
ThreadedSupervisor
(
numMessages
)).
start
for
(
_
<-
0
until
numRings
)
(
new
ThreadedChainMaster
(
s
)).
start
!
initMsg
}
else
if
(
impl
==
"threadless"
)
{
val
s
=
(
new
ThreadlessSupervisor
(
numMessages
)).
start
for
(
_
<-
0
until
numRings
)
(
new
ThreadlessChainMaster
(
s
)).
start
!
initMsg
}
else
if
(
impl
==
"akka"
)
{
val
system
=
ActorSystem
();
val
s
=
system
.
actorOf
(
Props
(
new
AkkaSupervisor
(
numMessages
)))
for
(
_
<-
0
until
numRings
)
system
.
actorOf
(
Props
(
new
AkkaChainMaster
(
s
)))
!
initMsg
global
.
latch
.
await
system
.
shutdown
System
.
exit
(
0
)
}
def
main
(
args
:
Array
[
String
])
:
Unit
=
args
match
{
case
Array
(
impl
,
IntStr
(
numRings
),
IntStr
(
ringSize
),
IntStr
(
initToken
),
IntStr
(
reps
))
=>
{
val
mc
=
new
MixedCase
(
numRings
,
ringSize
,
initToken
,
reps
);
impl
match
{
case
"threaded"
=>
mc
.
runThreaded
case
"threadless"
=>
mc
.
runThreadless
case
"akka"
=>
mc
.
runAkka
case
_
=>
usage
}
}
else
usage
case
_
=>
usage
}
}
benchmarks/scala/Utility.scala
0 → 100644
View file @
783b2413
package
org.libcppa.utility
object
IntStr
{
val
IntRegex
=
"([0-9]+)"
.
r
def
unapply
(
s
:
String
)
:
Option
[
Int
]
=
s
match
{
case
IntRegex
(
`s`
)
=>
Some
(
s
.
toInt
)
case
_
=>
None
}
}
object
KeyValuePair
{
val
Rx
=
"([^=])+=([^=]*)"
.
r
def
unapply
(
s
:
String
)
:
Option
[
Pair
[
String
,
String
]]
=
s
match
{
case
Rx
(
key
,
value
)
=>
Some
(
Pair
(
key
,
value
))
case
_
=>
None
}
}
class
Utility
{
}
benchmarks/scala_test.sh
View file @
783b2413
#!/bin/bash
#export JAVA_OPTS="-Xmx1024"
JARS
=
"
$AKKA_LIBS
"
:/home/neverlord/akka-2.0.1/lib/scala-library.jar:./scala/
echo
"java -cp
$JARS
$@
"
| ./exec.sh
if
[
!
-d
$PWD
/scala
]
;
then
echo
"
$PWD
/scala is not a valid directory!"
exit
fi
AKKA_LIBS
=
/
$HOME
/akka-2.0.3/lib/scala-library.jar
for
JAR
in
/
$HOME
/akka-2.0.3/lib/akka/
*
.jar
;
do
AKKA_LIBS
=
$JAR
:
$AKKA_LIBS
done
arg0
=
org.libcppa.
$1
.Main
shift
JARS
=
"
$AKKA_LIBS
"
:
$PWD
/scala/
echo
"java -cp
$JARS
$arg0
$@
"
| ./exec.sh
cppa.files
View file @
783b2413
...
...
@@ -265,3 +265,4 @@ src/buffer.cpp
cppa/message_future.hpp
cppa/detail/fd_util.hpp
src/fd_util.cpp
benchmarks/scala/Utility.scala
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