File: Float.hs

package info (click to toggle)
haskell-serialise 0.2.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 564 kB
  • sloc: haskell: 6,809; makefile: 6
file content (25 lines) | stat: -rw-r--r-- 806 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{-# LANGUAGE ScopedTypeVariables #-}

module Instances.Float
  ( benchmarks -- :: [Benchmark]
  ) where

import           Criterion.Main
import           Codec.Serialise
import           Control.DeepSeq (force)
import qualified Data.ByteString.Lazy as BSL

benchmarks :: [Benchmark]
benchmarks =
  [ bench "serialise Float" (whnf (BSL.length . serialise) fakesF)
  , bench "deserialise Float" (nf (deserialise :: BSL.ByteString -> [Float]) serialF)
  , bench "serialise Double" (whnf (BSL.length . serialise) fakesD)
  , bench "deserialise Double" (nf (deserialise :: BSL.ByteString -> [Double]) serialD)
  ]
  where
    fakesF = force (replicate 100 (3.14159 :: Float))
    fakesD = force (replicate 100 (3.14159 :: Double))

    serialF = force (serialise fakesF)
    serialD = force (serialise fakesD)