diff options
Diffstat (limited to 'src/edit_bench.erl')
-rw-r--r-- | src/edit_bench.erl | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/edit_bench.erl b/src/edit_bench.erl new file mode 100644 index 0000000..1c40925 --- /dev/null +++ b/src/edit_bench.erl @@ -0,0 +1,32 @@ +%%%------------------------------------------------------------------- +%%% File : edit_bench.erl +%%% Author : Luke Gorrie <luke@bluetail.com> +%%% Purpose : Random benchmarking +%%% +%%% Created : 29 Sep 2001 by Luke Gorrie <luke@bluetail.com> +%%%------------------------------------------------------------------- +-module(edit_bench). + +-compile(export_all). + +%% Testing the speed of sending (large) cords in messages + +cord_bench(Filename, N) -> + {ok, Cord} = cord:new_from_file(Filename), + Pid = spawn_link(?MODULE, cord_receiver, []), + timer:tc(?MODULE, cord_bench_loop, [Cord, Pid, N]). + +cord_bench_loop(Cord, Pid, 0) -> + exit(Pid, kill), + ok; +cord_bench_loop(Cord, Pid, N) when N > 0 -> + Pid ! {cord, self(), Cord}, + receive ack -> ok end, + cord_bench_loop(Cord, Pid, N-1). + +cord_receiver() -> + receive {cord, Who, Cord} -> Who ! ack end, + cord_receiver(). + + + |