summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@lshift.net>2009-04-12 19:54:19 +0100
committerMatthew Sackman <matthew@lshift.net>2009-04-12 19:54:19 +0100
commitf191d8413b4d0bdcf2f466da1dc5e42304bd241d (patch)
tree813a95a37264ab53ab34a6a14d20d2ca8a797a06 /src
parentcb87008620431c8f30269fba02f4aeffbc31e073 (diff)
downloadrabbitmq-server-git-f191d8413b4d0bdcf2f466da1dc5e42304bd241d.tar.gz
initial stab at some tests (though still only 1 queue!).
Also accidentally seem to have committed a change to the Makefile a while back so am undoing that.
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_tests.erl36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl
index 6312e8e364..0114eb2569 100644
--- a/src/rabbit_tests.erl
+++ b/src/rabbit_tests.erl
@@ -31,7 +31,9 @@
-module(rabbit_tests).
--export([all_tests/0, test_parsing/0]).
+-compile(export_all).
+
+-export([all_tests/0, test_parsing/0, test_disk_queue/0]).
-import(lists).
@@ -621,3 +623,35 @@ delete_log_handlers(Handlers) ->
[[] = error_logger:delete_report_handler(Handler) ||
Handler <- Handlers],
ok.
+
+test_disk_queue() ->
+ [begin rdq_time_tx_publish_commit(q, MsgCount, MsgSize), timer:sleep(1000) end || % 1000 milliseconds
+ MsgSize <- [128, 512, 2048, 8192, 32768, 131072],
+ MsgCount <- [1024, 2048, 4096, 8192, 16384]
+ ],
+ rdq_virgin().
+
+rdq_time_tx_publish_commit(Q, MsgCount, MsgSizeBytes) ->
+ rdq_virgin(),
+ rdq_start(),
+ Msg = <<0:(8*MsgSizeBytes)>>,
+ List = lists:seq(1, MsgCount),
+ {Micros, ok} = timer:tc(?MODULE, rdq_time_commands,
+ [[fun() -> [rabbit_disk_queue:tx_publish(N, Msg) || N <- List] end,
+ fun() -> rabbit_disk_queue:tx_commit(Q, List) end]]),
+ io:format("Published ~p ~p-byte messages in ~p microseconds (~p microseconds/msg) (~p microseconds/byte)~n", [MsgCount, MsgSizeBytes, Micros, (Micros / MsgCount), (Micros / MsgCount / MsgSizeBytes)]),
+ rdq_stop().
+
+rdq_time_commands(Funcs) ->
+ lists:foreach(fun (F) -> F() end, Funcs).
+
+rdq_virgin() ->
+ {Micros, {ok, _}} = timer:tc(rabbit_disk_queue, start_link, [1024*1024*10, 1000]),
+ io:format("Disk queue start up took ~p microseconds~n", [Micros]),
+ ok = rabbit_disk_queue:clean_stop().
+
+rdq_start() ->
+ {ok, _} = rabbit_disk_queue:start_link(1024*1024*10, 1000).
+
+rdq_stop() ->
+ rabbit_disk_queue:stop().