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
We have the withoutShrinking combinator that makes generators that we want to run only once against a SampleTree. Unfortunately, we currently have to re-run those generators every single time they run, which leads to pretty bad performance; this is most notable in tests that depend on fromShrinkTree; see the TestSuite.Sanity.Functions.StringToBool test one a particularly bad example.
It feels like it should be relatively simple to memoize these results. For example, we could imagine that shrinking could return new generators, such that if we have
replacing the generator by a constant one that just returns the value it produces. Unfortunately, this does not work: we cannot return new generators, because generators are monadic (how would we update a continuation a -> Gen b?).
The only state we have is in the SampleTree. Now, we could of course do something like this:
dataSample= .. | NotShrunkWord64 (MaybeDynamic)
where we cache the constructed value right in the same tree. This too would make sense, but it's unclear how this works with context re-interpretation . For example, what if we have a generator such as
example::Gen..
example =do
b <- bool
if b then once ..else once ..
We now run two different generators against the same sample tree; surely we don't expect to get the result from one of those generators in the other one? That would be very confusing (consider the case where one generator is prim, and the other (* 2) <$> prim or something like that; it would be very strange if we got an odd number out of that generator).
The text was updated successfully, but these errors were encountered:
Perhaps this is not sufficient, actually. When we are memoizing a shrink tree, we would still be retracing our steps through that shrink tree on each iteration; we would merely avoid building the shrink tree, which might not actually save us all that much time. Ideally we would memoize the most recently generated value, so that we only need to take a single step.
We have the
withoutShrinking
combinator that makes generators that we want to run only once against aSampleTree
. Unfortunately, we currently have to re-run those generators every single time they run, which leads to pretty bad performance; this is most notable in tests that depend onfromShrinkTree
; see theTestSuite.Sanity.Functions.StringToBool
test one a particularly bad example.It feels like it should be relatively simple to memoize these results. For example, we could imagine that shrinking could return new generators, such that if we have
then
replacing the generator by a constant one that just returns the value it produces. Unfortunately, this does not work: we cannot return new generators, because generators are monadic (how would we update a continuation
a -> Gen b
?).The only state we have is in the
SampleTree
. Now, we could of course do something like this:where we cache the constructed value right in the same tree. This too would make sense, but it's unclear how this works with context re-interpretation . For example, what if we have a generator such as
We now run two different generators against the same sample tree; surely we don't expect to get the result from one of those generators in the other one? That would be very confusing (consider the case where one generator is
prim
, and the other(* 2) <$> prim
or something like that; it would be very strange if we got an odd number out of that generator).The text was updated successfully, but these errors were encountered: