Hi. I'm just in my first days of testing with test.check and prismatic schema. I ran into performance issues right away as a suite of about 20 tests took already 80 seconds. Nope I'm not talking GUI. Those were generator-unit-tests. If anyone has the same problem, this is what helped me a lot: http://blog.muhuk.com/2015/09/17/performance_tuning_clojure_generative_tests.html#.VgjjWSCqpBc I decided to cache the really expensive datastructures. Now those same checks run in ~2.5 seconds
Cool! Good to know about your experience. I guess caching has to be taken with care, to not reduce the "randomness" so much, but seems like a good strategy when you have a combination of generators, some of which are "expensive". You lose the shrinking on them though...
@nberger: I think I don't lose the shrinking. But I can't repeat the checks. That's at least what the blog said and I think I got pretty ok results so far.
Yes, reducing the randomness too much will be contraproductive but I think I got enough from that still. Especially when I compile anew
@meikemertsch: I should have been more precise... you don't lose it, but you get shrinking of a different thing... From the example, the idea is to use something like:
(def gen-key
(let [ks (gen/sample gen/keyword 30)]
(gen/elements ks)))
instead of gen/keyword
Yes, gotcha so far..
Ah, I think I see where you're going
well, the shrinking of that (gen/elements ...)
runs by discarding elements from the left side, so giving more probability to the elements to the right...
that's not exactly the same as shrinking the keyword :foo
, which would give you something like :fo
or :f
I think...
It can't shrink as much as with genuinely generated data
Yes
what do you mean by "genuinely generated"? :simple_smile:
Directly generated I guess 😅
You mean "by hand"?
Without caching
:simple_smile:
Oh, ok
Well, imaging you would get :some-loong-keyword-with-+_weird-chars
from gen/keyword
, as opposed of it being one of the elements from that (gen/elements ...)
when shrinking, I guess that gen/keyword
will shrink towards shorter versions of that :some-loong...
keyword... (gen/elements ...)
will shrink toward elements to the right of that keyword, so it will give you a keyword that most probably will not be a shorter version of that keyword :simple_smile:
most of the times you won't care about this...
But I just wanted to point it out :simple_smile:
But there might be days ;) it's better to be aware! Thanks!
I learned something about the shrinking in that process 😅
But now I'll hit the sack. It's late here 😊
Cool :
:simple_smile: