nick8325 / quickcheck

Automatic testing of Haskell programs.
Other
724 stars 121 forks source link

Construction of `output` is slow due to appending at the end of a string #185

Closed sol closed 7 years ago

sol commented 7 years ago

Steps to reproduce:

import Test.QuickCheck
import System.Clock

main :: IO ()
main = measure $ quickCheckResult (verbose prop) >>= print . length . output

prop :: Property
prop = verbose $ \n -> (n == (23 :: Int)) ==> True

measure :: IO a -> IO a
measure action = do
  t0 <- getTime Monotonic
  a <- action
  t1 <- getTime Monotonic
  putStrLn (show (toNanoSecs (t1 - t0) `div` 1000000) ++ "ms")
  return a

On my box this takes more than 5 seconds to complete. If I don't look at the output, it's fast (< 500ms). The faulty code is in Test/QuickCheck/Text.hs, modifyIORef res (++ s).