[Haskell-cafe] Criterion setup/teardown functions?

2012-07-17 Thread tsuraan
Is there anything in Criterion that allows for a benchmark to run some
code before or after the thing that it's timing?  As an example, I'd
like to time a bunch of database inserts, but beforehand I want to
create the target table, and afterwards I'd like to delete it.  I
don't really care to have the time spent on the create/delete recorded
in the test run's timing, if that's possible to do.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Criterion setup/teardown functions?

2012-07-17 Thread Thomas Schilling
On 17 July 2012 20:45, tsuraan tsur...@gmail.com wrote:
 Is there anything in Criterion that allows for a benchmark to run some
 code before or after the thing that it's timing?  As an example, I'd
 like to time a bunch of database inserts, but beforehand I want to
 create the target table, and afterwards I'd like to delete it.  I
 don't really care to have the time spent on the create/delete recorded
 in the test run's timing, if that's possible to do.

See the second argument of defaultMainWith
http://hackage.haskell.org/packages/archive/criterion/0.6.0.0/doc/html/Criterion-Main.html#v:defaultMainWith.

The Criterion monad supports running arbitrary IO actions via liftIO.

/ Thomas

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Criterion setup/teardown functions?

2012-07-17 Thread tsuraan
 See the second argument of defaultMainWith
 http://hackage.haskell.org/packages/archive/criterion/0.6.0.0/doc/html/Criterion-Main.html#v:defaultMainWith.

the prep argument is run before the entire suite is run (i.e. once
per criterion main invocation); I'm looking for some way to run code
before and after each function being benchmarked (and different code
around different functions being benchmarked).

It looks like criterion is fairly hard-wired to time everything that
is done to run a test, so I guess the answer to my question is a
straightforward no :)  I think I'd have to modify the Benchmarkable
typeclass to have a setup and teardown in order to do what I want.
Maybe I'll give that a shot.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe