You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2017/07/13 17:59:34 UTC

[couchdb] 03/24: TMP: Simple benchmark script

This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch optimize-ddoc-cache
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 00ae4ca813a084263053601640d4e5a4391599cd
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Wed Jun 28 10:58:34 2017 -0500

    TMP: Simple benchmark script
---
 src/ddoc_cache/src/ddoc_cache_speed.erl | 61 +++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/src/ddoc_cache/src/ddoc_cache_speed.erl b/src/ddoc_cache/src/ddoc_cache_speed.erl
new file mode 100644
index 0000000..38cd0b9
--- /dev/null
+++ b/src/ddoc_cache/src/ddoc_cache_speed.erl
@@ -0,0 +1,61 @@
+-module(ddoc_cache_speed).
+
+-export([
+    go/1,
+    recover/1
+]).
+
+
+-define(RANGE, 1000).
+
+
+go(WorkerCount) when is_integer(WorkerCount), WorkerCount > 0 ->
+    spawn_workers(WorkerCount),
+    report().
+
+
+recover(DbName) ->
+    {ok, {stuff, DbName}}.
+
+
+spawn_workers(0) ->
+    ok;
+
+spawn_workers(WorkerCount) ->
+    Self = self(),
+    WorkerDb = list_to_binary(integer_to_list(WorkerCount)),
+    spawn(fun() ->
+        do_work(Self, WorkerDb, 0)
+    end),
+    spawn_workers(WorkerCount - 1).
+
+
+do_work(Parent, WorkerDb, Count) when Count >= 25 ->
+    Parent ! {done, Count},
+    do_work(Parent, WorkerDb, 0);
+
+do_work(Parent, WorkerDb, Count) ->
+    {ok, _} = ddoc_cache:open_custom(WorkerDb, ?MODULE),
+    do_work(Parent, WorkerDb, Count + 1).
+
+
+report() ->
+    report(os:timestamp(), 0).
+
+
+report(Start, Count) ->
+    Now = os:timestamp(),
+    case timer:now_diff(Now, Start) of
+        N when N > 1000000 ->
+            {_, MQL} = process_info(whereis(ddoc_cache_lru), message_queue_len),
+            io:format("~p ~p~n", [Count, MQL]),
+            report(Now, 0);
+        _ ->
+            receive
+                {done, Done} ->
+                    report(Start, Count + Done)
+            after 100 ->
+                report(Start, Count)
+            end
+    end.
+

-- 
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.