File: JacobiBench.hs

package info (click to toggle)
haskell-arithmoi 0.13.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 964 kB
  • sloc: haskell: 10,379; makefile: 3
file content (21 lines) | stat: -rw-r--r-- 708 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{-# OPTIONS_GHC -fno-warn-type-defaults #-}

module Math.NumberTheory.JacobiBench
  ( benchSuite
  ) where

import Test.Tasty.Bench
import Numeric.Natural

import Math.NumberTheory.Moduli.Sqrt

doBench :: Integral a => (a -> a -> JacobiSymbol) -> a -> a
doBench func lim = sum [ x + y | y <- [3, 5 .. lim], x <- [0..y], func x y == One ]

benchSuite :: Benchmark
benchSuite = bgroup "Jacobi"
  [ bench "jacobi/Int"      $ nf (doBench jacobi  :: Int -> Int)         2000
  , bench "jacobi/Word"     $ nf (doBench jacobi  :: Word -> Word)       2000
  , bench "jacobi/Integer"  $ nf (doBench jacobi  :: Integer -> Integer) 2000
  , bench "jacobi/Natural"  $ nf (doBench jacobi  :: Natural -> Natural) 2000
  ]