packages feed

genvalidity-criterion (empty) → 0.0.0.0

raw patch · 4 files changed

+175/−0 lines, 4 filesdep +QuickCheckdep +basedep +criterion

Dependencies added: QuickCheck, base, criterion, deepseq, genvalidity, genvalidity-criterion

Files

+ LICENSE view
@@ -0,0 +1,21 @@+The MIT License (MIT)++Copyright (c) 2016-2020 Tom Sydney Kerckhove++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.
+ bench/Main.hs view
@@ -0,0 +1,49 @@+{-# LANGUAGE AllowAmbiguousTypes #-}+{-# LANGUAGE TypeApplications #-}+{-# LANGUAGE ScopedTypeVariables #-}++module Main where++import Data.Fixed+import Data.Int+import Data.List.NonEmpty (NonEmpty(..))+import Data.Ratio+import Data.Word+import Numeric.Natural++import Criterion.Main as Criterion++import Data.GenValidity.Criterion++main :: IO ()+main =+  Criterion.defaultMain+    [ genValidBench @()+    , genValidBench @Bool+    , genValidBench @Ordering+    , genValidBench @Char+    , genValidBench @Int+    , genValidBench @(Int, Int)+    , genValidBench @(Int, Int, Int)+    , genValidBench @(Int, Int, Int, Int)+    , genValidBench @(Maybe Int)+    , genValidBench @(Either Int Int)+    , genValidBench @[Int]+    , genValidBench @[[Int]]+    , genValidBench @(NonEmpty Int)+    , genValidBench @(NonEmpty (NonEmpty Int))+    , genValidBench @(Ratio Int)+    , genValidBench @Int8+    , genValidBench @Int16+    , genValidBench @Int32+    , genValidBench @Int64+    , genValidBench @Integer+    , genValidBench @Word8+    , genValidBench @Word16+    , genValidBench @Word32+    , genValidBench @Word64+    , genValidBench @Natural+    , genValidBench @Float+    , genValidBench @Double+    , genValidBench @(Fixed E12)+    ]
+ genvalidity-criterion.cabal view
@@ -0,0 +1,55 @@+cabal-version: 1.12++-- This file has been generated from package.yaml by hpack version 0.33.0.+--+-- see: https://github.com/sol/hpack+--+-- hash: 55f101899e3757aeae67655460610eadf78922eb5e875e50782dc9f090bf4467++name:           genvalidity-criterion+version:        0.0.0.0+synopsis:       Criterion benchmarks for generators+category:       Validity+homepage:       https://github.com/NorfairKing/validity#readme+bug-reports:    https://github.com/NorfairKing/validity/issues+author:         Tom Sydney Kerckhove+maintainer:     syd@cs-syd.eu+copyright:      Copyright: (c) 2018-2020 Tom Sydney Kerckhove+license:        MIT+license-file:   LICENSE+build-type:     Simple++source-repository head+  type: git+  location: https://github.com/NorfairKing/validity++library+  exposed-modules:+      Data.GenValidity.Criterion+  other-modules:+      Paths_genvalidity_criterion+  hs-source-dirs:+      src+  build-depends:+      QuickCheck+    , base <5+    , criterion+    , deepseq+    , genvalidity+  default-language: Haskell2010++benchmark genvalidity-criterion-bench+  type: exitcode-stdio-1.0+  main-is: Main.hs+  other-modules:+      Paths_genvalidity_criterion+  hs-source-dirs:+      bench/+  ghc-options: -Wall+  build-depends:+      QuickCheck+    , base <5+    , criterion+    , genvalidity+    , genvalidity-criterion+  default-language: Haskell2010
+ src/Data/GenValidity/Criterion.hs view
@@ -0,0 +1,50 @@+{-# LANGUAGE AllowAmbiguousTypes #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeApplications #-}++-- | Benchmarks for generators+module Data.GenValidity.Criterion+  ( genValidityBench+  , genUncheckedBench+  , genValidBench+  , genBench+  ) where++import Control.DeepSeq+import Data.GenValidity+import Data.Typeable+import Test.QuickCheck++import Criterion++-- | Benchmarks for both genUnchecked and genValid+genValidityBench ::+     forall a. (Typeable a, NFData a, GenUnchecked a, GenValid a)+  => Benchmark+genValidityBench =+  bgroup (unwords ["GenValidity", nameOf @a]) [genValidBench @a, genUncheckedBench @a]++-- | Benchmarks for both genUnchecked+genUncheckedBench ::+     forall a. (Typeable a, NFData a, GenUnchecked a)+  => Benchmark+genUncheckedBench = genBench (unwords ["genUnchecked", nameOf @a]) (genUnchecked @a)++-- | Benchmarks for both genValid+genValidBench ::+     forall a. (Typeable a, NFData a, GenValid a)+  => Benchmark+genValidBench = genBench (unwords ["genValid", nameOf @a]) (genValid @a)++-- | Benchmarks a generator with a given name+genBench :: NFData a => String -> Gen a -> Benchmark+genBench name gen = bench name $ nfIO $ generate (resize 30 gen)++nameOf ::+     forall a. Typeable a+  => String+nameOf =+  let s = show $ typeRep (Proxy @a)+   in if ' ' `elem` s+        then "(" ++ s ++ ")"+        else s