Skip to content

powModInteger slower than computing pow and mod separately

module Foo where

import GHC.Integer.GMP.Internals ( powModInteger )

test1, test2 :: Integer -> Integer -> Int -> Integer

test1 a b c = (a ^ b) `mod` (2^c)

test2 a b c = powModInteger a b (2^c)

I was expecting test2 to perform better than test1, but I'm getting quite the opposite: the use of powModInteger seems to be several orders of magnitude slower.

I have tested this with GHC 7.10.2 and integer-gmp 1.0.0.0 too, with similar results.

Trac metadata
Trac field Value
Version 7.8.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Core Libraries
Test case
Differential revisions
BlockedBy
Related
Blocking
CC ekmett
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information