@@ -1,15 +1,20 @@
1-module(throughput).
1-module(throughput).
3−-export([start_counter/0, start_count/2, counter/0, count/2]).
3+-export([start_counter/0, start_count/3, counter/0, count/3, nats/1]).
5counter() ->
10counter() ->
6 counter(0).
11 counter(0).
8counter(N) ->
13counter(N) ->
10− nothing ->
15+ {count, List} ->
11− counter(N + 1);
16+ counter(N + length(List));
12− {just, Them} ->
17+ {get, Them} ->
14 counter(0)
19 counter(0)
@@ -20,9 +25,9 @@ replicate(N, What) ->
21 replicate(N - 1, What).
26 replicate(N - 1, What).
23−count(N, Them) ->
28+count(Packets, Size, Them) ->
24− replicate(N, fun() -> {counter, Them} ! nothing end),
29+ replicate(Packets, fun() -> {counter, Them} ! {count, nats(Size)} end),
25− {counter, Them} ! {just, self()},
30+ {counter, Them} ! {get, self()},
27 N -> io:format("Did ~B pings", [N])
32 N -> io:format("Did ~B pings", [N])
@@ -30,5 +35,5 @@ count(N, Them) ->
30start_counter() ->
35start_counter() ->
31 register(counter, spawn(throughput, counter, [])).
36 register(counter, spawn(throughput, counter, [])).
33−start_count(N, Them) ->
38+start_count(Packets, Size, Them) ->
34− count(N, Them).
39+ count(Packets, Size, Them).