mirror of
https://github.com/anoma/juvix.git
synced 2024-12-02 10:47:32 +03:00
3a4cbc742d
The following benchmark compares juvix 0.6.0 with polysemy and a new version (implemented in this pr) which replaces polysemy by effectful. # Typecheck standard library without caching ``` hyperfine --warmup 2 --prepare 'juvix-polysemy clean' 'juvix-polysemy typecheck Stdlib/Prelude.juvix' 'juvix-effectful typecheck Stdlib/Prelude.juvix' Benchmark 1: juvix-polysemy typecheck Stdlib/Prelude.juvix Time (mean ± σ): 3.924 s ± 0.143 s [User: 3.787 s, System: 0.084 s] Range (min … max): 3.649 s … 4.142 s 10 runs Benchmark 2: juvix-effectful typecheck Stdlib/Prelude.juvix Time (mean ± σ): 2.558 s ± 0.074 s [User: 2.430 s, System: 0.084 s] Range (min … max): 2.403 s … 2.646 s 10 runs Summary juvix-effectful typecheck Stdlib/Prelude.juvix ran 1.53 ± 0.07 times faster than juvix-polysemy typecheck Stdlib/Prelude.juvix ``` # Typecheck standard library with caching ``` hyperfine --warmup 1 'juvix-effectful typecheck Stdlib/Prelude.juvix' 'juvix-polysemy typecheck Stdlib/Prelude.juvix' --min-runs 20 Benchmark 1: juvix-effectful typecheck Stdlib/Prelude.juvix Time (mean ± σ): 1.194 s ± 0.068 s [User: 0.979 s, System: 0.211 s] Range (min … max): 1.113 s … 1.307 s 20 runs Benchmark 2: juvix-polysemy typecheck Stdlib/Prelude.juvix Time (mean ± σ): 1.237 s ± 0.083 s [User: 0.997 s, System: 0.231 s] Range (min … max): 1.061 s … 1.476 s 20 runs Summary juvix-effectful typecheck Stdlib/Prelude.juvix ran 1.04 ± 0.09 times faster than juvix-polysemy typecheck Stdlib/Prelude.juvix ```
53 lines
1.3 KiB
Haskell
53 lines
1.3 KiB
Haskell
module PolysemyPrelude
|
|
( module PolysemyPrelude,
|
|
module Polysemy,
|
|
module Polysemy.Error,
|
|
module Polysemy.Input,
|
|
module Polysemy.Fixpoint,
|
|
module Polysemy.Output,
|
|
module Polysemy.Reader,
|
|
module Polysemy.Tagged,
|
|
module Polysemy.Resource,
|
|
module Polysemy.Scoped,
|
|
module Polysemy.State,
|
|
)
|
|
where
|
|
|
|
import Data.Stream qualified as Stream
|
|
import Juvix.Prelude.Base.Foundation
|
|
import Polysemy hiding (embed)
|
|
import Polysemy.Embed qualified as Embed
|
|
import Polysemy.Error hiding (fromEither)
|
|
import Polysemy.Fixpoint
|
|
import Polysemy.Input
|
|
import Polysemy.Output
|
|
import Polysemy.Reader
|
|
import Polysemy.Resource
|
|
import Polysemy.Scoped
|
|
import Polysemy.State
|
|
import Polysemy.Tagged hiding (tag)
|
|
|
|
type EmbedIO = Embed.Embed IO
|
|
|
|
embed :: (Member EmbedIO r) => IO a -> Sem r a
|
|
embed = Embed.embed
|
|
|
|
mapReader :: (Member (Reader e1) r) => (e1 -> e2) -> Sem (Reader e2 ': r) a -> Sem r a
|
|
mapReader f s = do
|
|
e <- ask
|
|
runReader (f e) s
|
|
|
|
execOutputList :: Sem (Output o ': r) a -> Sem r [o]
|
|
execOutputList = fmap fst . runOutputList
|
|
|
|
runInputInfinite :: Stream i -> Sem (Input i ': r) a -> Sem r a
|
|
runInputInfinite s =
|
|
evalState s
|
|
. reinterpret
|
|
( \case
|
|
Input -> do
|
|
Stream.Cons i is <- get
|
|
put is
|
|
return i
|
|
)
|