hedgehogqa / hedgehogqa/fsharp-hedgehog

Generation is order of magnitude slower than FsCheck

Open
#135 29 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
F#
Stars
284
Forks
31
PR merge metrics
No merged PRs in 30d

Description

Hedgehog generates strings (haven't tested other types) more than an order of magnitude slower than FsCheck.

I discovered this after converting tests from FsCheck to Hedgehog and noticing a drastic slowdown of the test suite.

Code to test:

```f#
module H =

open Hedgehog

let s = Gen.string (Range.singleton 10) Gen.alphaNum

let check () = s |> Gen.sample 0 10000

module F =

open FsCheck

let alphaNum = ['0'..'9'] @ ['A'..'Z'] @ ['a'..'z']

let s = Gen.elements alphaNum
|> Gen.listOfLength 10
|> Gen.map (fun cs -> System.String.Concat(Array.ofList(cs)))

let check () = s |> Gen.sample 0 10000

```

Result of interactive execution using `#time`:

```
> F.check();;
> Real: 00:00:00.057, CPU: 00:00:00.062, GC gen0: 11, gen1: 0, gen2: 0
val it : string list =
["mj3bVSmKEY"; "smj3bVSmKE"; "Ksmj3bVSmK"; "dKsmj3bVSm"; "OdKsmj3bVS";
"LOdKsmj3bV"; "VLOdKsmj3b"; "7VLOdKsmj3"; "X7VLOdKsmj"; "xX7VLOdKsm"; ...]

> H.check();;
> Real: 00:00:01.838, CPU: 00:00:01.890, GC gen0: 52, gen1: 14, gen2: 3
val it : List =
["ffmhtVdB5q"; "283b0i3P88"; "RZUYtob07L"; "PSEp4C9Q1c"; "PkPv63NQ83";
"b9Gnw9ZN7N"; "3HFgXJB5tl"; "TcwRo7AjON"; "HfZGkhHb0h"; "Oj6Fg0RyBw"; ...]
```

Notice the insane difference: 57 ms for FsCheck vs. 1838 ms for Hedgehog.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.