File: GaussianIntegersBench.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 (24 lines) | stat: -rw-r--r-- 803 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
22
23
24
{-# OPTIONS_GHC -fno-warn-type-defaults #-}

module Math.NumberTheory.GaussianIntegersBench
  ( benchSuite
  ) where

import Data.Maybe
import Test.Tasty.Bench

import Math.NumberTheory.ArithmeticFunctions (tau)
import Math.NumberTheory.Primes (isPrime)
import Math.NumberTheory.Quadratic.GaussianIntegers

benchFindPrime :: Integer -> Benchmark
benchFindPrime n = bench (show n) $ nf findPrime (fromJust (isPrime n))

benchTau :: Integer -> Benchmark
benchTau n = bench (show n) $ nf (\m -> sum [tau (x :+ y) | x <- [1..m], y <- [0..m]] :: Word) n

benchSuite :: Benchmark
benchSuite = bgroup "Gaussian"
  [ bgroup "findPrime" $ map benchFindPrime [1000033, 10000121, 100000037, 1000000009, 10000000033, 100000000057, 1000000000061, 10000000000037]
  , bgroup "tau" $ map benchTau [10, 20, 40, 80]
  ]