scalacheck integration

131 views
Skip to first unread message

Eugene Platonov

unread,
Jan 24, 2013, 1:31:55 AM1/24/13
to scala...@googlegroups.com
Hey All,
I was recently toying with scalameter and it happened that the first thing I was trying to benchmark was sorting. 
So I've implemented couple of sorting algorithms and then have written some simple benchmarks using scalameter. 
Then I've realized that scalameter will always give me same arrays, and even worse they are always sorted. So the easy way was to shuffle arrays before sorting, but I thought that having some random array generators would be nice as well. 
As a result I've got a very simple scalachek integration - an implicit conversion from scalacheck Gen to scalameter Gen. Then benchmarking with it has been quite simple.

The code sampe

    import org.scalameter.Gen
    import org.scalacheck.{Gen => SGen}
       
          ...

    def random: Gen[(Int, SGen[Int])] = for {
      size <- sizes
      randomGen = SGen.choose(0, size)
    } yield (size, randomGen)

    def randomArrays: Gen[Array[Int]] = for {
      (size, r) <- random
      array <- SGen.containerOfN[Array, Int](size, r)
    } yield array



I know that scalameter Gens are different from scalacheck Gens, but I see some usages of them together, like in my example.
So my question is do you think it could be useful for someone else? I can create a PR if that's the case

~
Thanks,
Eugene

lossyrob

unread,
Nov 21, 2013, 2:57:03 PM11/21/13
to scala...@googlegroups.com
Hi Eugene,

Did this PR ever get made? I'm interested in something similar, for doing benchmarking on random geometries generated by scalacheck.

Thanks,
Rob

Eugene Platonov

unread,
Dec 2, 2013, 7:28:15 PM12/2/13
to scala...@googlegroups.com
Hi Rob,
no one seemed interested in it, so I never pushed it.
You can take a look at what I have in my fork https://github.com/jozic/scalameter/tree/scalacheck-integration
It's quite old though.

~

Thanks,
Eugene
Reply all
Reply to author
Forward
0 new messages