in reply to Re^5: Random data generation.
in thread Random data generation.
Actually, the number of reps allowed is the one parameter that doesn't vary for my scenario. Also, the length of the string will never be less than the size of the set.
The approach you use in salva2 is very interesting, and does make it come out first in every benchmark I've run. One of my own alternatives used a similar approach: Generate a big string completely at random and then pick out a compliant N-char length lump with a regex and return it. Your innovations of a) making the whole string compliant using a regex, b) retaining the buffer across calls; combine to make the approach viable.
The funny thing is that I'm already effectively using the latter part in my code (but not the benchmarks), in as much as I need a bunch of short strings, but I'm calling the generator for one long string and then chopping it into bits using unpack "(A$N)*', gen( $N * 100, @set ). That negates a part of salva2's advantage, and also trades the cost of unpack against the cost of multiple calls to the generator.
Now I have to consider whether your generate a big string and the regex it into compliance approach would still be quicker in-situ. It's not an easy thing to benchmark. Neither is considering the affect it has on the randomness of the result.
It's quite amazing how many variations can result from an ostensibly simple spec. Many thanks for your input.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Random data generation.
by salva (Canon) on Jun 28, 2010 at 13:23 UTC | |
by BrowserUk (Patriarch) on Jun 28, 2010 at 13:41 UTC |