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
undistort is a relatively expensive operation, taking around 0.3s. Therefore it's important that we only distort when we really need to - which is exactly when a new frame comes in (from a web camera). However, the above seems to result in undistort being evaluated whenever I need the value of the currentFrameBehavior. The following rewrite evaluates undistort only when necessary:
It does look undesirable to me that the two code snippets have different performance characteristics.
At the moment, the internal implementation of reactive-banana uses different mechanisms for memoizing Event compared to memoizing Behavior values. The latter is not quite as good as the former, hence the discrepancy. That said, I'm not entirely sure why it doesn't work in this case.
Running this, "frames" arrive every 3 seconds, and pressing enter prints the value of the behavior that is updated by an expensive pure function every frame.
If I run this and press enter a bunch, I only see the expensive operation computed once per new frame, and between frames, it's cached.
We have the following code in our application:
undistort
is a relatively expensive operation, taking around 0.3s. Therefore it's important that we only distort when we really need to - which is exactly when a new frame comes in (from a web camera). However, the above seems to result inundistort
being evaluated whenever I need the value of thecurrentFrame
Behavior
. The following rewrite evaluatesundistort
only when necessary:Is this to be expected?
The text was updated successfully, but these errors were encountered: