File: Time.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 (22 lines) | stat: -rw-r--r-- 749 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
{-# LANGUAGE ScopedTypeVariables #-}

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

import           Criterion.Main
import           Data.Time.Clock (UTCTime(..))
import           Data.Time.Calendar (Day(..))
import           Codec.Serialise
import           Control.DeepSeq (force)
import qualified Data.ByteString.Lazy as BSL

benchmarks :: [Benchmark]
benchmarks =
  [ bench "serialise UTCTime" (whnf (BSL.length . serialise) timestamps)
  , bench "deserialise UTCTime" (nf (deserialise :: BSL.ByteString -> [UTCTime]) serialisedTimestamps)
  ]
  where
    faketime             = UTCTime (ModifiedJulianDay 0) 0
    timestamps           = force (replicate 100 faketime)
    serialisedTimestamps = force (serialise timestamps)