couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [couchdb] 02/02: TMP: Simple benchmark script
Date Fri, 30 Jun 2017 15:47:57 GMT
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 747c248704889042c32effa0cfcd3ef8e2ca5a43
Author: Paul J. Davis <paul.joseph.davis@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" <commits@couchdb.apache.org>.

Mime
View raw message