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
0b1c3a8f
Commit
0b1c3a8f
authored
Apr 30, 2012
by
neverlord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
distributed benchmark
parent
0c3537cb
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
27 deletions
+26
-27
benchmarks/distributed.cpp
benchmarks/distributed.cpp
+8
-8
benchmarks/distributed.erl
benchmarks/distributed.erl
+17
-18
benchmarks/erlang_test.sh
benchmarks/erlang_test.sh
+1
-1
No files found.
benchmarks/distributed.cpp
View file @
0b1c3a8f
...
...
@@ -76,23 +76,23 @@ 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 "
<<
" example: mode=benchmark 192.168.9.1:1234 "
"192.168.9.2:1234 "
"--num_pings=100"
<<
endl
<<
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
...
...
@@ -467,16 +467,16 @@ int main(int argc, char** argv)
{
usage
();
},
on
(
"
--
mode=server"
)
>>
[
=
]()
on
(
"mode=server"
)
>>
[
=
]()
{
server_mode
(
first
+
1
,
last
);
},
on
(
"
--
mode=benchmark"
)
>>
[
=
]()
on
(
"mode=benchmark"
)
>>
[
=
]()
{
client_mode
(
first
+
1
,
last
);
await_all_others_done
();
},
on
(
"
--
mode=shutdown"
)
>>
[
=
]()
on
(
"mode=shutdown"
)
>>
[
=
]()
{
shutdown_mode
(
first
+
1
,
last
);
},
...
...
benchmarks/distributed.erl
View file @
0b1c3a8f
...
...
@@ -5,7 +5,7 @@ ping_loop(Parent, Pong) ->
receive
{
pong
,
0
}
->
Parent
!
done
;
{
pong
,
X
}
->
Pong
!
{
self
(),
ping
,
X
-
1
},
Pong
!
{
ping
,
self
()
,
X
-
1
},
ping_loop
(
Parent
,
Pong
);
{
kickoff
,
Value
}
->
Pong
!
{
ping
,
self
(),
Value
},
...
...
@@ -14,7 +14,7 @@ ping_loop(Parent, Pong) ->
server_loop
(
Pongs
)
->
receive
{
ping
,
Pid
,
Value
}
->
Pid
!
{
pong
,
Value
};
{
ping
,
Pid
,
Value
}
->
Pid
!
{
pong
,
Value
}
,
server_loop
(
Pongs
)
;
{
add_pong
,
Pid
,
Node
}
->
case
lists
:
any
(
fun
({
N
,
_})
->
N
==
Node
end
,
Pongs
)
of
true
->
...
...
@@ -41,17 +41,17 @@ server_mode() ->
add_pong_fun
(_,
_,
[])
->
true
;
add_pong_fun
(
Pong
,
Node
,
[
Node
|
T
])
->
add_pong_fun
(
Pong
,
Node
,
T
);
add_pong_fun
(
Pong
,
Node
,
[
H
|
T
])
->
Pong
!
{
add_pong
,
H
},
Pong
!
{
add_pong
,
self
(),
H
},
receive
{
ok
}
->
add_pong_fun
(
Pong
,
Node
,
T
);
{
error
,
Reason
}
->
error
(
Reason
)
after
10000
->
error
(
timeout
)
end
.
% receive a {done} message for each node
client_mode
([],
[],
[],
_)
->
true
;
client_mode
([],
[],
[_|
T
],
NumPings
)
->
receive
{
done
}
->
receive
done
->
client_mode
([],
[],
T
,
NumPings
)
end
;
...
...
@@ -65,29 +65,28 @@ client_mode(Pongs, [H|T], Nodes, NumPings) ->
{
badrpc
,
Reason
}
->
io
:
format
(
"cannot connect to
~s~n
"
,
[
atom_to_list
(
H
)]),
error
(
Reason
);
undefined
->
io
:
format
(
"no 'pong' defined on node
~s~n
"
,
[
atom_to_list
(
H
)]);
P
->
add_pong_fun
(
P
,
H
,
Nodes
),
client_mode
(
Pongs
++
[
P
],
T
,
Nodes
,
NumPings
)
end
.
run
([],
undefined
,
[
'mode=server'
])
->
server_mode
();
run
(_,
undefined
,
[])
->
error
(
"NumPings is undefined"
);
run
(
Hosts
,
_,
[])
when
length
(
Hosts
)
<
2
->
error
(
"less than two nodes specified"
);
run
(
Hosts
,
NumPings
,
[])
->
client_mode
([],
Hosts
,
Hosts
,
NumPings
);
run
(
Hosts
,
NumPings
,
[
H
|
T
])
->
Arg
=
atom_to_list
(
H
),
SetNumPings
=
lists
:
prefix
(
"num_pings="
,
Arg
),
if
SetNumPings
==
true
andalso
NumPings
/=
undefined
->
error
(
"NumPings already set"
);
SetNumPings
==
true
->
run
(
Hosts
,
list_to_integer
(
lists
:
sublist
(
Arg
,
11
,
length
(
Arg
))),
T
);
true
->
run
(
Hosts
++
[
H
],
NumPings
,
T
)
case
lists
:
prefix
(
"num_pings="
,
Arg
)
of
true
when
NumPings
/=
undefined
->
error
(
"NumPings already set"
);
true
->
run
(
Hosts
,
list_to_integer
(
lists
:
sublist
(
Arg
,
11
,
length
(
Arg
))),
T
);
false
->
run
(
Hosts
++
[
H
],
NumPings
,
T
)
end
.
start
(
X
)
->
run
([],
undefined
,
X
).
case
X
of
[
'mode=server'
|[]]
->
server_mode
();
[
'mode=server'
|_]
->
io
:
format
(
"too much arguments
~n
"
,
[]);
[
'mode=benchmark'
|
T
]
->
run
([],
undefined
,
T
);
_
->
io
:
format
(
"invalid arguments
~n
"
,
[])
end
.
benchmarks/erlang_test.sh
View file @
0b1c3a8f
#!/bin/bash
echo
"erl -noshell -noinput +P 20000000 -s
$@
-s init stop"
| ./exec.sh
echo
"erl -noshell -noinput +P 20000000 -s
name benchmark -s
$@
-s init stop"
| ./exec.sh
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