From 63dad3f785a76f8e06fc20cdce69aeefc4488289 Mon Sep 17 00:00:00 2001 From: Christopher Date: Thu, 16 Apr 2020 20:50:04 -0500 Subject: [PATCH] time publish resource --- lib/router/session.ex | 44 ++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/lib/router/session.ex b/lib/router/session.ex index dc81df2..9bf5294 100644 --- a/lib/router/session.ex +++ b/lib/router/session.ex @@ -323,23 +323,27 @@ defmodule Wampex.Router.Session do {data, actions} = case is_authorized?(am, peer, :publish, topic) do true -> - pub_id = RealmSession.get_id() - - subs = RealmSession.subscriptions(db, realm, topic) - details = Map.put_new(opts, "topic", topic) - - Enum.each(subs, fn {id, {pid, node}} -> - send( - {proxy, node}, - {%Event{ - subscription_id: id, - publication_id: pub_id, - arg_list: arg_l, - arg_kw: arg_kw, - details: details - }, pid} - ) - end) + {id_time, pub_id} = :timer.tc(fn -> RealmSession.get_id() end) + + {subs_time, subs} = :timer.tc(fn -> RealmSession.subscriptions(db, realm, topic) end) + + {put_time, details} = :timer.tc(fn -> Map.put_new(opts, "topic", topic) end) + + {send_time, _} = + :timer.tc(fn -> + Enum.each(subs, fn {id, {pid, node}} -> + send( + {proxy, node}, + {%Event{ + subscription_id: id, + publication_id: pub_id, + arg_list: arg_l, + arg_kw: arg_kw, + details: details + }, pid} + ) + end) + end) case opts do %{"acknowledge" => true} -> @@ -349,6 +353,12 @@ defmodule Wampex.Router.Session do :noop end + Logger.info( + "ID Time: #{inspect(id_time)} \n SUBS Time: #{inspect(subs_time)} \n PUT Time: #{inspect(put_time)} \n SEND Time: #{ + inspect(send_time) + }" + ) + {sl, [{:next_event, :internal, :transition}]} false -> -- 2.45.3