packages feed

zwirn-0.2.2.0: bench/Core/Main.hs

{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# OPTIONS_GHC -Wno-orphans #-}

module Main where

import Control.DeepSeq
import Criterion.Main
import Data.Functor.Identity
import GHC.Generics (Generic)
import Zwirn.Core.Cord (Cord, stack)
import qualified Zwirn.Core.Lib.Core as C
import Zwirn.Core.Lib.Modulate (fast)
import Zwirn.Core.Query
import Zwirn.Core.Time (Time (..))
import Zwirn.Core.Types (ZwirnT)

deriving instance Generic Time

deriving instance NFData Time

test :: Cord () () Int
test = fast (stack (replicate 10 (pure 23))) $ stack (replicate 10 (pure 1))

test2 :: Cord () () Int
test2 = C.iterate (pure 100) (pure $ fmap (+ 1)) test

test3 :: ZwirnT Identity () () Int
test3 = fast (pure 23) (pure 1)

main :: IO ()
main =
  defaultMain
    [ bgroup
        "oldquery"
        [ bench "" $ nf (\arc -> findAllValuesWithTime arc () test) (0, 1),
          bench "" $ nf (\arc -> findAllValuesWithTime arc () test2) (0, 1),
          bench "" $ nf (\arc -> findAllValuesWithTime arc () test3) (0, 1)
        ]
    ]