File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -546,3 +546,14 @@ test-suite functora-test
546
546
, tags
547
547
, uri
548
548
, web
549
+
550
+ benchmark functora-bench
551
+ import : pkg, exe
552
+ type : exitcode-stdio-1.0
553
+ main-is : Main.hs
554
+ hs-source-dirs : src/bench
555
+ build-depends :
556
+ , base
557
+ , criterion
558
+ , functora
559
+ , QuickCheck
Original file line number Diff line number Diff line change
1
+ import Criterion.Main
2
+ import Functora.Prelude
3
+ import Test.QuickCheck hiding (Fixed )
4
+ import Test.QuickCheck.Gen (unGen )
5
+ import Test.QuickCheck.Random (newQCGen )
6
+
7
+ mkSamples :: Int -> IO [Fix ]
8
+ mkSamples n = do
9
+ gen <- newQCGen
10
+ pure . fmap Fix $ unGen (vectorOf n arbitrary) gen n
11
+
12
+ main :: IO ()
13
+ main = do
14
+ samples <- mkSamples 1000000
15
+ defaultMain
16
+ [ bgroup
17
+ " Fix -> Double"
18
+ [ bench " via Rational" $
19
+ whnf (map $ from @ Fix @ Double ) samples
20
+ ]
21
+ ]
Original file line number Diff line number Diff line change @@ -209,6 +209,7 @@ import Data.Fixed as X
209
209
Pico ,
210
210
showFixed ,
211
211
)
212
+ import qualified Data.Fixed
212
213
import Data.Foldable1 as X (Foldable1 , fold1 , foldMap1 )
213
214
import Data.Functor.Contravariant as X (contramap )
214
215
import Data.Generics as X (Data )
You can’t perform that action at this time.
0 commit comments