Skip to content

Instantly share code, notes, and snippets.

createNode(NodeNumber, NumberOfNodes, NextNode) ->
createNode(NodeNumber + 1, NumberOfNodes, spawn(?MODULE, loop, [NextNode])).
createNode(NumberOfNodes, NumberOfNodes, NextNode) -> NextNode;
-module (e24).
-compile (export_all).
ringBenchmark(NumberOfNodes, _Message, NumberOfLaps) ->
statistics(runtime),
statistics(wall_clock),
FirstNode = spawn(?MODULE, loop, [[]]),
LastNode = createNode(1, NumberOfNodes, FirstNode),
FirstNode ! LastNode,
Eshell V5.7.4 (abort with ^G)
1> c(e23).
{ok,e23}
2> e23:ringBenchmark(4, "Hello", 5).
Sent 20 messages in time=0 (0) milliseconds
Spawned with NextNode []
Spawned with NextNode <0.39.0>
Spawned with NextNode <0.40.0>
Spawned with NextNode <0.41.0>
ok
-module (e23).
-compile (export_all).
ringBenchmark(NumberOfNodes, _Message, NumberOfLaps) ->
statistics(runtime),
statistics(wall_clock),
FirstNode = spawn(?MODULE, loop, [[]]),
_LastNode = createNode(1, NumberOfNodes, FirstNode),
1> c(e22).
{ok,e22}
2> e22:ringBenchmark(4, "Hello", 5).
Sent 20 messages in time=0 (0) milliseconds
Spawned with NextNode []
ok
3>
@quamen
quamen / e22.erl
Created November 17, 2010 08:29
Timing code with something to do.
-module (e22).
-compile (export_all).
ringBenchmark(NumberOfNodes, _Message, NumberOfLaps) ->
statistics(runtime),
statistics(wall_clock),
_FirstNode = spawn(?MODULE, loop, [[]]),
{_, Time1} = statistics(runtime),
@quamen
quamen / e21-output.txt
Created November 17, 2010 08:25
Running the benchmark code
Eshell V5.7.4 (abort with ^G)
1> c(e21).
{ok,e21}
2> e21:ringBenchmark(4, "Hello", 5).
Sent 20 messages in time=0 (0) milliseconds
ok
3>
@quamen
quamen / e23.erl
Created November 17, 2010 08:20
Timing Code
-module (e21).
-compile (export_all).
ringBenchmark(NumberOfNodes, _Message, NumberOfLaps) ->
statistics(runtime),
statistics(wall_clock),
{_, Time1} = statistics(runtime),
{_, Time2} = statistics(wall_clock),
io:format("Sent ~p messages in time=~p (~p) milliseconds~n", [NumberOfLaps * NumberOfNodes, Time1, Time2]).
@quamen
quamen / capybara
Created October 21, 2010 05:26
write a step that uses the post method and store the response, access it in a later step
@response = post(
"my/awesome/url",
json_content,
{"Content-Type" => "application/json"}
)