main = defaultMain
    [ bgroup "std ops"
        [ bench "mod" $ nf (mod lg1) lg2
        , bench "rem" $ nf (rem lg1) lg2
        , bench "div" $ nf (div lg1) lg2
        , bench "quot" $ nf (quot lg1) lg2
        , bench "divmod" $ nf (divMod lg1) lg2
        , bench "quotRem" $ nf (quotRem lg1) lg2
        ]
    , bgroup "divMod by 256"
        [ bench "divmod 256" $ nf (divMod lg1) 256
        , bench "quotRem 256" $ nf (quotRem lg1) 256
        , bench "modAndShift 8" $ nf (modAndShift8 lg1) 8
        , bench "bitsAndShift 8" $ nf (bitsAndShift8 lg1) 8
        ]
    , bgroup "serialization bs->i"
        [ bench "8"    $ nf os2ip b8
        , bench "32"   $ nf os2ip b32
        , bench "64"   $ nf os2ip b64
        , bench "256"  $ nf os2ip b256
        , bench "1024" $ nf os2ip b1024
        ]
    , bgroup "serialization i->bs"
        [ bench "10"     $ nf i2osp (2^10)
        , bench "100"    $ nf i2osp (2^100)
        , bench "1000"   $ nf i2osp (2^1000)
        , bench "10000"  $ nf i2osp (2^10000)
        , bench "100000" $ nf i2osp (2^100000)
        ]
    , bgroup "serialization i->bs of size"
        [ bench "10"     $ nf (i2ospOf_ 4) (2^10)
        , bench "100"    $ nf (i2ospOf_ 16) (2^100)
        , bench "1000"   $ nf (i2ospOf_ 128) (2^1000)
        , bench "10000"  $ nf (i2ospOf_ 1560) (2^10000)
        , bench "100000" $ nf (i2ospOf_ 12502) (2^100000)
        ]
    , bgroup "exponentiation"
        [ bench "2^1234 mod 2^999" $ nf (exponantiation 2 1234) (2^999)
        , bench "130^5432 mod 100^9990" $ nf (exponantiation 130 5432) (100^9999)
        , bench "2^1234 mod 2^999" $ nf (exponantiation_rtl_binary 2 1234) (2^999)
        , bench "130^5432 mod 100^9990" $ nf (exponantiation_rtl_binary 130 5432) (100^9999)
        ]
    , bgroup "F2m"
        [ bench "addition" $ nf (addF2m lg1) lg2
        , bench "multiplication" $ nf (mulF2m fx lg1) lg2
        , bench "square" $ nf (squareF2m fx) lg1
        , bench "square multiplication" $ nf (mulF2m fx lg1) lg1
        , bench "reduction" $ nf (modF2m fx) lg1
        , bench "inversion" $ nf (invF2m fx) lg1
        ]
    ]
    where b8    = B.replicate 8 0xf7
          b32   = B.replicate 32 0xf7
          b64   = B.replicate 64 0x7f
          b256  = B.replicate 256 0x7f
          b1024 = B.replicate 1024 0x7f
main = defaultMain
    [ bgroup "std ops"
        [ bench "mod" $ nf (mod lg1) lg2
        , bench "rem" $ nf (rem lg1) lg2
        , bench "div" $ nf (div lg1) lg2
        , bench "quot" $ nf (quot lg1) lg2
        , bench "divmod" $ nf (divMod lg1) lg2
        , bench "quotRem" $ nf (quotRem lg1) lg2
        ]
    , bgroup "divMod by 256"
        [ bench "divmod 256" $ nf (divMod lg1) 256
        , bench "quotRem 256" $ nf (quotRem lg1) 256
        , bench "modAndShift 8" $ nf (modAndShift8 lg1) 8
        , bench "bitsAndShift 8" $ nf (bitsAndShift8 lg1) 8
        ]
    , bgroup "serialization bs->i"
        [ bench "8"    $ nf os2ip b8
        , bench "32"   $ nf os2ip b32
        , bench "64"   $ nf os2ip b64
        , bench "256"  $ nf os2ip b256
        , bench "1024" $ nf os2ip b1024
        ]
    , bgroup "serialization i->bs"
        [ bench "10"     $ nf i2osp (2^10)
        , bench "100"    $ nf i2osp (2^100)
        , bench "1000"   $ nf i2osp (2^1000)
        , bench "10000"  $ nf i2osp (2^10000)
        , bench "100000" $ nf i2osp (2^100000)
        ]
    , bgroup "serialization i->bs of size"
        [ bench "10"     $ nf (i2ospOf_ 4) (2^10)
        , bench "100"    $ nf (i2ospOf_ 16) (2^100)
        , bench "1000"   $ nf (i2ospOf_ 128) (2^1000)
        , bench "10000"  $ nf (i2ospOf_ 1560) (2^10000)
        , bench "100000" $ nf (i2ospOf_ 12502) (2^100000)
        ]
    , bgroup "exponentiation"
        [ bench "2^1234 mod 2^999" $ nf (exponantiation 2 1234) (2^999)
        , bench "130^5432 mod 100^9990" $ nf (exponantiation 130 5432) (100^9999)
        , bench "2^1234 mod 2^999" $ nf (exponantiation_rtl_binary 2 1234) (2^999)
        , bench "130^5432 mod 100^9990" $ nf (exponantiation_rtl_binary 130 5432) (100^9999)
        ]
    , bgroup "F2m"
        [ bench "addition" $ nf (addF2m lg1) lg2
        , bench "multiplication" $ nf (mulF2m fx lg1) lg2
        , bench "square" $ nf (squareF2m fx) lg1
        , bench "square multiplication" $ nf (mulF2m fx lg1) lg1
        , bench "reduction" $ nf (modF2m fx) lg1
        , bench "inversion" $ nf (invF2m fx) lg1
        ]
    ]
    where b8    = B.replicate 8 0xf7
          b32   = B.replicate 32 0xf7
          b64   = B.replicate 64 0x7f
          b256  = B.replicate 256 0x7f
          b1024 = B.replicate 1024 0x7f
main = defaultMain
    [ bgroup "std ops"
        [ bench "mod" $ nf (mod lg1) lg2
        , bench "rem" $ nf (rem lg1) lg2
        , bench "div" $ nf (div lg1) lg2
        , bench "quot" $ nf (quot lg1) lg2
        , bench "divmod" $ nf (divMod lg1) lg2
        , bench "quotRem" $ nf (quotRem lg1) lg2
        ]
    , bgroup "divMod by 256"
        [ bench "divmod 256" $ nf (divMod lg1) 256
        , bench "quotRem 256" $ nf (quotRem lg1) 256
        , bench "modAndShift 8" $ nf (modAndShift8 lg1) 8
        , bench "bitsAndShift 8" $ nf (bitsAndShift8 lg1) 8
        ]
    , bgroup "serialization bs->i"
        [ bench "8"    $ nf os2ip b8
        , bench "32"   $ nf os2ip b32
        , bench "64"   $ nf os2ip b64
        , bench "256"  $ nf os2ip b256
        , bench "1024" $ nf os2ip b1024
        ]
    , bgroup "serialization i->bs"
        [ bench "10"     $ nf i2osp (2^10)
        , bench "100"    $ nf i2osp (2^100)
        , bench "1000"   $ nf i2osp (2^1000)
        , bench "10000"  $ nf i2osp (2^10000)
        , bench "100000" $ nf i2osp (2^100000)
        ]
    , bgroup "serialization i->bs of size"
        [ bench "10"     $ nf (i2ospOf_ 4) (2^10)
        , bench "100"    $ nf (i2ospOf_ 16) (2^100)
        , bench "1000"   $ nf (i2ospOf_ 128) (2^1000)
        , bench "10000"  $ nf (i2ospOf_ 1560) (2^10000)
        , bench "100000" $ nf (i2ospOf_ 12502) (2^100000)
        ]
    , bgroup "exponentiation"
        [ bench "2^1234 mod 2^999" $ nf (exponantiation 2 1234) (2^999)
        , bench "130^5432 mod 100^9990" $ nf (exponantiation 130 5432) (100^9999)
        , bench "2^1234 mod 2^999" $ nf (exponantiation_rtl_binary 2 1234) (2^999)
        , bench "130^5432 mod 100^9990" $ nf (exponantiation_rtl_binary 130 5432) (100^9999)
        ]
    , bgroup "F2m"
        [ bench "addition" $ nf (addF2m lg1) lg2
        , bench "multiplication" $ nf (mulF2m fx lg1) lg2
        , bench "square" $ nf (squareF2m fx) lg1
        , bench "square multiplication" $ nf (mulF2m fx lg1) lg1
        , bench "reduction" $ nf (modF2m fx) lg1
        , bench "inversion" $ nf (invF2m fx) lg1
        ]
    ]
    where b8    = B.replicate 8 0xf7
          b32   = B.replicate 32 0xf7
          b64   = B.replicate 64 0x7f
          b256  = B.replicate 256 0x7f
          b1024 = B.replicate 1024 0x7f