You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to my profiler when I evaluate JS and return some arrays it eats almost 70% of time:
def reduce_props(object_id, to)
15.00% if cyclic?(object_id).dig("result", "value")
return to.is_a?(Array) ? [cyclic_object] :
else
20.00% props = @page.command("Runtime.getPropertie
66.91% props["result"].reduce(to) do |memo, prop|
next(memo) unless prop["enumerable"]
66.82% yield(memo, prop["name"], prop["value"])
end
end
end
For example, I'm not sure if it's correct that it yields a block with handle_response because it calls cyclic? again on each nesting.
UPD: or do I understand right that it's purpose is in calling the Runtime.getProperties otherwise the evaluated return value isn't unfolded into nested Ruby arrays, and cyclic? is enable to go though it neither?
UPD: is it a protocol limitation that we can't move the deserialisation of the nested objects to JS?
P.S.: my returning object is in fact an array of size ~3000 with elements that are two object arrays [node, string, boolean], so I suppose it calls a nested handle_response ~3000 times.
UPD: flattened the returning array to then do .each_slice(3) on the Ruby level in my program -- became two times faster:
def reduce_props(object_id, to)
0.37% if cyclic?(object_id).dig("result", "value")
return to.is_a?(Array) ? [cyclic_object] :
else
0.73% props = @page.command("Runtime.getPropertie
38.05% props["result"].reduce(to) do |memo, prop|
next(memo) unless prop["enumerable"]
38.00% yield(memo, prop["name"], prop["value"])
end
end
end
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
According to my profiler when I evaluate JS and return some arrays it eats almost 70% of time:
For example, I'm not sure if it's correct that it yields a block with
handle_response
because it callscyclic?
again on each nesting.UPD: or do I understand right that it's purpose is in calling the
Runtime.getProperties
otherwise the evaluated return value isn't unfolded into nested Ruby arrays, andcyclic?
is enable to go though it neither?UPD: is it a protocol limitation that we can't move the deserialisation of the nested objects to JS?
P.S.: my returning object is in fact an array of size ~3000 with elements that are two object arrays
[node, string, boolean]
, so I suppose it calls a nestedhandle_response
~3000 times.UPD: flattened the returning array to then do
.each_slice(3)
on the Ruby level in my program -- became two times faster:Beta Was this translation helpful? Give feedback.
All reactions