From 2e298a62f7cb8683f60660ec9996c602268170a9 Mon Sep 17 00:00:00 2001 From: Vadim Tsvetkov Date: Sat, 18 Dec 2021 21:40:47 +0300 Subject: [PATCH 1/4] Delete unused `h` helper in Arrow.FunctionBench --- bench/witchcraft/apply/function_bench.exs | 3 +++ bench/witchcraft/apply/list_bench.exs | 2 ++ bench/witchcraft/apply/tuple_bench.exs | 2 ++ bench/witchcraft/arrow/function_bench.exs | 1 - 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/bench/witchcraft/apply/function_bench.exs b/bench/witchcraft/apply/function_bench.exs index 9a06b77..8de13e3 100644 --- a/bench/witchcraft/apply/function_bench.exs +++ b/bench/witchcraft/apply/function_bench.exs @@ -1,7 +1,10 @@ defmodule Witchcraft.Apply.FunBench do + @moduledoc false + use Benchfella use Witchcraft.Apply + ######### # Setup # ######### diff --git a/bench/witchcraft/apply/list_bench.exs b/bench/witchcraft/apply/list_bench.exs index 4f34a25..b8fad1f 100644 --- a/bench/witchcraft/apply/list_bench.exs +++ b/bench/witchcraft/apply/list_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Apply.ListBench do + @moduledoc false + use Benchfella use Witchcraft.Apply diff --git a/bench/witchcraft/apply/tuple_bench.exs b/bench/witchcraft/apply/tuple_bench.exs index 7c1f2a5..5b3e72e 100644 --- a/bench/witchcraft/apply/tuple_bench.exs +++ b/bench/witchcraft/apply/tuple_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Apply.TupleBench do + @moduledoc false + use Benchfella use Witchcraft.Apply diff --git a/bench/witchcraft/arrow/function_bench.exs b/bench/witchcraft/arrow/function_bench.exs index dcf5686..ec399bf 100644 --- a/bench/witchcraft/arrow/function_bench.exs +++ b/bench/witchcraft/arrow/function_bench.exs @@ -15,7 +15,6 @@ defmodule Witchcraft.Arrow.FunctionBench do defp f(x), do: "#{inspect x}/#{inspect x}" defp g(y), do: "#{inspect y}-#{inspect y}-#{inspect y}" - defp h(z), do: "!#{inspect y}!" ######### # Arrow # From dc967fc09ebaa6f12f802f43c6e9ba035a8a325b Mon Sep 17 00:00:00 2001 From: Vadim Tsvetkov Date: Sat, 18 Dec 2021 22:30:33 +0300 Subject: [PATCH 2/4] Add moduledoc attribues to benchmarks --- bench/witchcraft/applicative/function_bench.exs | 2 ++ bench/witchcraft/applicative/list_bench.exs | 2 ++ bench/witchcraft/applicative/tuple_bench.exs | 2 ++ bench/witchcraft/arrow/function_bench.exs | 2 ++ bench/witchcraft/bifunctor/tuple_bench.exs | 2 ++ bench/witchcraft/category/function_bench.exs | 2 ++ bench/witchcraft/chain/function_bench.exs | 2 ++ bench/witchcraft/chain/list_bench.exs | 2 ++ bench/witchcraft/chain/tuple_bench.exs | 2 ++ bench/witchcraft/comonad/tuple_bench.exs | 2 ++ bench/witchcraft/extend/function_bench.exs | 2 ++ bench/witchcraft/extend/list_bench.exs | 2 ++ bench/witchcraft/extend/tuple_bench.exs | 2 ++ bench/witchcraft/foldable/bitstring_bench.exs | 2 ++ bench/witchcraft/foldable/list_bench.exs | 2 ++ bench/witchcraft/foldable/map_bench.exs | 2 ++ bench/witchcraft/foldable/tuple_bench.exs | 2 ++ bench/witchcraft/functor/function_bench.exs | 2 ++ bench/witchcraft/functor/list_bench.exs | 2 ++ bench/witchcraft/functor/map_bench.exs | 2 ++ bench/witchcraft/functor/tuple_bench.exs | 2 ++ bench/witchcraft/monad/function_bench.exs | 2 ++ bench/witchcraft/monad/list_bench.exs | 2 ++ bench/witchcraft/monad/tuple_bench.exs | 2 ++ bench/witchcraft/monoid/bitstring_bench.exs | 2 ++ bench/witchcraft/monoid/float_bench.exs | 2 ++ bench/witchcraft/monoid/function_bench.exs | 2 ++ bench/witchcraft/monoid/integer_bench.exs | 2 ++ bench/witchcraft/monoid/list_bench.exs | 2 ++ bench/witchcraft/monoid/map_bench.exs | 2 ++ bench/witchcraft/monoid/map_set_bench.exs | 2 ++ bench/witchcraft/monoid/tuple_bench.exs | 2 ++ bench/witchcraft/ord/bitstring.exs | 2 ++ bench/witchcraft/ord/float_bench.exs | 2 ++ bench/witchcraft/ord/integer_bench.exs | 2 ++ bench/witchcraft/ord/list_bench.exs | 2 ++ bench/witchcraft/ord/map_bench.exs | 2 ++ bench/witchcraft/ord/tuple_bench.exs | 2 ++ bench/witchcraft/semigroup/bitstring_bench.exs | 2 ++ bench/witchcraft/semigroup/float_bench.exs | 2 ++ bench/witchcraft/semigroup/function_bench.exs | 2 ++ bench/witchcraft/semigroup/integer_bench.exs | 2 ++ bench/witchcraft/semigroup/list_bench.exs | 2 ++ bench/witchcraft/semigroup/map_bench.exs | 2 ++ bench/witchcraft/semigroup/mapset_bench 2.exs | 2 ++ bench/witchcraft/semigroup/mapset_bench.exs | 2 ++ bench/witchcraft/semigroup/tuple_bench.exs | 2 ++ bench/witchcraft/semigroupoid/function_bench.exs | 2 ++ bench/witchcraft/setoid/bitstring_bench.exs | 2 ++ bench/witchcraft/setoid/float_bench.exs | 2 ++ bench/witchcraft/setoid/integer_bench.exs | 2 ++ bench/witchcraft/setoid/list_bench.exs | 2 ++ bench/witchcraft/setoid/map_bench.exs | 2 ++ bench/witchcraft/setoid/map_set_bench.exs | 2 ++ bench/witchcraft/setoid/tuple_bench.exs | 2 ++ bench/witchcraft/traversable/list_bench.exs | 2 ++ bench/witchcraft/traversable/tuple_bench.exs | 2 ++ bench/witchcraft/unit_bench.exs | 2 ++ 58 files changed, 116 insertions(+) diff --git a/bench/witchcraft/applicative/function_bench.exs b/bench/witchcraft/applicative/function_bench.exs index c59be7f..7574d62 100644 --- a/bench/witchcraft/applicative/function_bench.exs +++ b/bench/witchcraft/applicative/function_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Applicative.FunctionBench do + @moduledoc false + use Benchfella use Witchcraft.Applicative diff --git a/bench/witchcraft/applicative/list_bench.exs b/bench/witchcraft/applicative/list_bench.exs index cb9796d..a5b6a20 100644 --- a/bench/witchcraft/applicative/list_bench.exs +++ b/bench/witchcraft/applicative/list_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Applicative.ListBench do + @moduledoc false + use Benchfella use Witchcraft.Applicative diff --git a/bench/witchcraft/applicative/tuple_bench.exs b/bench/witchcraft/applicative/tuple_bench.exs index 32bb148..4fd1f5f 100644 --- a/bench/witchcraft/applicative/tuple_bench.exs +++ b/bench/witchcraft/applicative/tuple_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Applicative.TupleBench do + @moduledoc false + use Benchfella use Witchcraft.Applicative diff --git a/bench/witchcraft/arrow/function_bench.exs b/bench/witchcraft/arrow/function_bench.exs index ec399bf..76c15d5 100644 --- a/bench/witchcraft/arrow/function_bench.exs +++ b/bench/witchcraft/arrow/function_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Arrow.FunctionBench do + @moduledoc false + use Benchfella use Witchcraft.Arrow diff --git a/bench/witchcraft/bifunctor/tuple_bench.exs b/bench/witchcraft/bifunctor/tuple_bench.exs index 8adaff6..09219f4 100644 --- a/bench/witchcraft/bifunctor/tuple_bench.exs +++ b/bench/witchcraft/bifunctor/tuple_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Bifunctor.TupleBench do + @moduledoc false + use Benchfella use Witchcraft.Bifunctor diff --git a/bench/witchcraft/category/function_bench.exs b/bench/witchcraft/category/function_bench.exs index 0ab44ac..22248b3 100644 --- a/bench/witchcraft/category/function_bench.exs +++ b/bench/witchcraft/category/function_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Category.FunctionBench do + @moduledoc false + use Benchfella use Witchcraft.Category diff --git a/bench/witchcraft/chain/function_bench.exs b/bench/witchcraft/chain/function_bench.exs index 870491b..4afaae7 100644 --- a/bench/witchcraft/chain/function_bench.exs +++ b/bench/witchcraft/chain/function_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Chain.FunctionBench do + @moduledoc false + use Benchfella use Witchcraft.Chain diff --git a/bench/witchcraft/chain/list_bench.exs b/bench/witchcraft/chain/list_bench.exs index c86fc63..eab944c 100644 --- a/bench/witchcraft/chain/list_bench.exs +++ b/bench/witchcraft/chain/list_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Chain.ListBench do + @moduledoc false + use Benchfella use Witchcraft.Chain diff --git a/bench/witchcraft/chain/tuple_bench.exs b/bench/witchcraft/chain/tuple_bench.exs index 6170159..6b84669 100644 --- a/bench/witchcraft/chain/tuple_bench.exs +++ b/bench/witchcraft/chain/tuple_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Chain.TupleBench do + @moduledoc false + use Benchfella use Witchcraft.Chain diff --git a/bench/witchcraft/comonad/tuple_bench.exs b/bench/witchcraft/comonad/tuple_bench.exs index 800b53d..be978b4 100644 --- a/bench/witchcraft/comonad/tuple_bench.exs +++ b/bench/witchcraft/comonad/tuple_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Comonad.TupleBench do + @moduledoc false + use Benchfella use Witchcraft.Comonad diff --git a/bench/witchcraft/extend/function_bench.exs b/bench/witchcraft/extend/function_bench.exs index 6e8945d..3323ce7 100644 --- a/bench/witchcraft/extend/function_bench.exs +++ b/bench/witchcraft/extend/function_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Extend.FunctionBench do + @moduledoc false + use Benchfella use Witchcraft.Extend use Quark diff --git a/bench/witchcraft/extend/list_bench.exs b/bench/witchcraft/extend/list_bench.exs index d3e5777..3eea1ab 100644 --- a/bench/witchcraft/extend/list_bench.exs +++ b/bench/witchcraft/extend/list_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Extend.ListBench do + @moduledoc false + use Benchfella use Witchcraft.Extend diff --git a/bench/witchcraft/extend/tuple_bench.exs b/bench/witchcraft/extend/tuple_bench.exs index 416ebf7..c14755b 100644 --- a/bench/witchcraft/extend/tuple_bench.exs +++ b/bench/witchcraft/extend/tuple_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Extend.TupleBench do + @moduledoc false + use Benchfella use Witchcraft.Extend diff --git a/bench/witchcraft/foldable/bitstring_bench.exs b/bench/witchcraft/foldable/bitstring_bench.exs index 474b09a..069bfe1 100644 --- a/bench/witchcraft/foldable/bitstring_bench.exs +++ b/bench/witchcraft/foldable/bitstring_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Foldable.BitStringBench do + @moduledoc false + require Integer use Benchfella diff --git a/bench/witchcraft/foldable/list_bench.exs b/bench/witchcraft/foldable/list_bench.exs index 1d0364c..311b8fd 100644 --- a/bench/witchcraft/foldable/list_bench.exs +++ b/bench/witchcraft/foldable/list_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Foldable.ListBench do + @moduledoc false + require Integer use Benchfella diff --git a/bench/witchcraft/foldable/map_bench.exs b/bench/witchcraft/foldable/map_bench.exs index 08ab693..e2d650a 100644 --- a/bench/witchcraft/foldable/map_bench.exs +++ b/bench/witchcraft/foldable/map_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Foldable.MapBench do + @moduledoc false + require Integer use Benchfella diff --git a/bench/witchcraft/foldable/tuple_bench.exs b/bench/witchcraft/foldable/tuple_bench.exs index aea6c44..dc60f43 100644 --- a/bench/witchcraft/foldable/tuple_bench.exs +++ b/bench/witchcraft/foldable/tuple_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Foldable.TupleBench do + @moduledoc false + require Integer use Benchfella diff --git a/bench/witchcraft/functor/function_bench.exs b/bench/witchcraft/functor/function_bench.exs index fc96783..c87e49e 100644 --- a/bench/witchcraft/functor/function_bench.exs +++ b/bench/witchcraft/functor/function_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Functor.FunctionBench do + @moduledoc false + use Benchfella use Witchcraft.Functor diff --git a/bench/witchcraft/functor/list_bench.exs b/bench/witchcraft/functor/list_bench.exs index cf1eff9..eaea2f7 100644 --- a/bench/witchcraft/functor/list_bench.exs +++ b/bench/witchcraft/functor/list_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Functor.ListBench do + @moduledoc false + use Benchfella use Witchcraft.Functor diff --git a/bench/witchcraft/functor/map_bench.exs b/bench/witchcraft/functor/map_bench.exs index d7deda5..49d55a3 100644 --- a/bench/witchcraft/functor/map_bench.exs +++ b/bench/witchcraft/functor/map_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Functor.MapBench do + @moduledoc false + use Benchfella use Witchcraft.Functor diff --git a/bench/witchcraft/functor/tuple_bench.exs b/bench/witchcraft/functor/tuple_bench.exs index 8a6e966..1782fca 100644 --- a/bench/witchcraft/functor/tuple_bench.exs +++ b/bench/witchcraft/functor/tuple_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Functor.TupleBench do + @moduledoc false + use Benchfella use Witchcraft.Functor diff --git a/bench/witchcraft/monad/function_bench.exs b/bench/witchcraft/monad/function_bench.exs index dc4a84e..b99f96b 100644 --- a/bench/witchcraft/monad/function_bench.exs +++ b/bench/witchcraft/monad/function_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Monad.FunctionBench do + @moduledoc false + use Benchfella use Witchcraft.Monad use Quark diff --git a/bench/witchcraft/monad/list_bench.exs b/bench/witchcraft/monad/list_bench.exs index b44991a..2f13ca0 100644 --- a/bench/witchcraft/monad/list_bench.exs +++ b/bench/witchcraft/monad/list_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Monad.ListBench do + @moduledoc false + use Benchfella use Witchcraft.Monad use Quark diff --git a/bench/witchcraft/monad/tuple_bench.exs b/bench/witchcraft/monad/tuple_bench.exs index 5744b14..d59055f 100644 --- a/bench/witchcraft/monad/tuple_bench.exs +++ b/bench/witchcraft/monad/tuple_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Monad.TupleBench do + @moduledoc false + use Benchfella use Witchcraft.Monad use Quark diff --git a/bench/witchcraft/monoid/bitstring_bench.exs b/bench/witchcraft/monoid/bitstring_bench.exs index ff3ba7e..e2254f7 100644 --- a/bench/witchcraft/monoid/bitstring_bench.exs +++ b/bench/witchcraft/monoid/bitstring_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Monoid.BitStringBench do + @moduledoc false + use Benchfella use Witchcraft.Monoid diff --git a/bench/witchcraft/monoid/float_bench.exs b/bench/witchcraft/monoid/float_bench.exs index 677e605..ea39011 100644 --- a/bench/witchcraft/monoid/float_bench.exs +++ b/bench/witchcraft/monoid/float_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Monoid.FloatBench do + @moduledoc false + use Benchfella use Witchcraft.Monoid diff --git a/bench/witchcraft/monoid/function_bench.exs b/bench/witchcraft/monoid/function_bench.exs index ca72c87..787d8a6 100644 --- a/bench/witchcraft/monoid/function_bench.exs +++ b/bench/witchcraft/monoid/function_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Monoid.FunctionBench do + @moduledoc false + use Benchfella use Witchcraft.Monoid diff --git a/bench/witchcraft/monoid/integer_bench.exs b/bench/witchcraft/monoid/integer_bench.exs index 723d9d8..ed6fdeb 100644 --- a/bench/witchcraft/monoid/integer_bench.exs +++ b/bench/witchcraft/monoid/integer_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Monoid.IntegerBench do + @moduledoc false + use Benchfella use Witchcraft.Monoid diff --git a/bench/witchcraft/monoid/list_bench.exs b/bench/witchcraft/monoid/list_bench.exs index 102ef08..d871609 100644 --- a/bench/witchcraft/monoid/list_bench.exs +++ b/bench/witchcraft/monoid/list_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Monoid.ListBench do + @moduledoc false + use Benchfella use Witchcraft.Monoid diff --git a/bench/witchcraft/monoid/map_bench.exs b/bench/witchcraft/monoid/map_bench.exs index 5dd2cab..881cb7b 100644 --- a/bench/witchcraft/monoid/map_bench.exs +++ b/bench/witchcraft/monoid/map_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Monoid.MapBench do + @moduledoc false + use Benchfella use Witchcraft.Monoid diff --git a/bench/witchcraft/monoid/map_set_bench.exs b/bench/witchcraft/monoid/map_set_bench.exs index ae19653..8bb86dc 100644 --- a/bench/witchcraft/monoid/map_set_bench.exs +++ b/bench/witchcraft/monoid/map_set_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Monoid.MapSetBench do + @moduledoc false + use Benchfella use Witchcraft.Monoid diff --git a/bench/witchcraft/monoid/tuple_bench.exs b/bench/witchcraft/monoid/tuple_bench.exs index fadf7f7..c94c15a 100644 --- a/bench/witchcraft/monoid/tuple_bench.exs +++ b/bench/witchcraft/monoid/tuple_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Monoid.TupleBench do + @moduledoc false + use Benchfella use Witchcraft.Monoid diff --git a/bench/witchcraft/ord/bitstring.exs b/bench/witchcraft/ord/bitstring.exs index 82e1830..5a4c532 100644 --- a/bench/witchcraft/ord/bitstring.exs +++ b/bench/witchcraft/ord/bitstring.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Ord.BitStringBench do + @moduledoc false + use Benchfella use Witchcraft.Ord diff --git a/bench/witchcraft/ord/float_bench.exs b/bench/witchcraft/ord/float_bench.exs index e918eb2..83218a9 100644 --- a/bench/witchcraft/ord/float_bench.exs +++ b/bench/witchcraft/ord/float_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Ord.FloatBench do + @moduledoc false + use Benchfella use Witchcraft.Ord diff --git a/bench/witchcraft/ord/integer_bench.exs b/bench/witchcraft/ord/integer_bench.exs index ffa70db..3a92a63 100644 --- a/bench/witchcraft/ord/integer_bench.exs +++ b/bench/witchcraft/ord/integer_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Ord.IntegerBench do + @moduledoc false + use Benchfella use Witchcraft.Ord diff --git a/bench/witchcraft/ord/list_bench.exs b/bench/witchcraft/ord/list_bench.exs index 96f100a..df5cf5a 100644 --- a/bench/witchcraft/ord/list_bench.exs +++ b/bench/witchcraft/ord/list_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Ord.ListBench do + @moduledoc false + use Benchfella use Witchcraft.Ord diff --git a/bench/witchcraft/ord/map_bench.exs b/bench/witchcraft/ord/map_bench.exs index dbffea2..9e6b3a5 100644 --- a/bench/witchcraft/ord/map_bench.exs +++ b/bench/witchcraft/ord/map_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Ord.MapBench do + @moduledoc false + use Benchfella use Witchcraft.Ord diff --git a/bench/witchcraft/ord/tuple_bench.exs b/bench/witchcraft/ord/tuple_bench.exs index 02c43ea..09769d8 100644 --- a/bench/witchcraft/ord/tuple_bench.exs +++ b/bench/witchcraft/ord/tuple_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Ord.TupleBench do + @moduledoc false + use Benchfella use Witchcraft.Ord diff --git a/bench/witchcraft/semigroup/bitstring_bench.exs b/bench/witchcraft/semigroup/bitstring_bench.exs index 6f1884c..3af33e7 100644 --- a/bench/witchcraft/semigroup/bitstring_bench.exs +++ b/bench/witchcraft/semigroup/bitstring_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Semigroup.BitStringBench do + @moduledoc false + use Benchfella use Witchcraft.Semigroup diff --git a/bench/witchcraft/semigroup/float_bench.exs b/bench/witchcraft/semigroup/float_bench.exs index f5e798a..77ab9ab 100644 --- a/bench/witchcraft/semigroup/float_bench.exs +++ b/bench/witchcraft/semigroup/float_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Semigroup.FloatBench do + @moduledoc false + use Benchfella use Witchcraft.Semigroup diff --git a/bench/witchcraft/semigroup/function_bench.exs b/bench/witchcraft/semigroup/function_bench.exs index 5be2620..128bfd0 100644 --- a/bench/witchcraft/semigroup/function_bench.exs +++ b/bench/witchcraft/semigroup/function_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Semigroup.FunctionBench do + @moduledoc false + use Benchfella use Witchcraft.Semigroup diff --git a/bench/witchcraft/semigroup/integer_bench.exs b/bench/witchcraft/semigroup/integer_bench.exs index 8c03efa..3f379da 100644 --- a/bench/witchcraft/semigroup/integer_bench.exs +++ b/bench/witchcraft/semigroup/integer_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Semigroup.IntegerBench do + @moduledoc false + use Benchfella use Witchcraft.Semigroup diff --git a/bench/witchcraft/semigroup/list_bench.exs b/bench/witchcraft/semigroup/list_bench.exs index b672885..2911d8d 100644 --- a/bench/witchcraft/semigroup/list_bench.exs +++ b/bench/witchcraft/semigroup/list_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Semigroup.ListBench do + @moduledoc false + use Benchfella use Witchcraft.Semigroup diff --git a/bench/witchcraft/semigroup/map_bench.exs b/bench/witchcraft/semigroup/map_bench.exs index e81b6b4..b4aeeed 100644 --- a/bench/witchcraft/semigroup/map_bench.exs +++ b/bench/witchcraft/semigroup/map_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Semigroup.MapBench do + @moduledoc false + use Benchfella use Witchcraft.Semigroup diff --git a/bench/witchcraft/semigroup/mapset_bench 2.exs b/bench/witchcraft/semigroup/mapset_bench 2.exs index 5352e1d..827f57e 100644 --- a/bench/witchcraft/semigroup/mapset_bench 2.exs +++ b/bench/witchcraft/semigroup/mapset_bench 2.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Semigroup.MapBench do + @moduledoc false + use Benchfella use Witchcraft.Semigroup diff --git a/bench/witchcraft/semigroup/mapset_bench.exs b/bench/witchcraft/semigroup/mapset_bench.exs index b4abfce..a5f3ee2 100644 --- a/bench/witchcraft/semigroup/mapset_bench.exs +++ b/bench/witchcraft/semigroup/mapset_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Semigroup.MapSetBench do + @moduledoc false + use Benchfella use Witchcraft.Semigroup diff --git a/bench/witchcraft/semigroup/tuple_bench.exs b/bench/witchcraft/semigroup/tuple_bench.exs index b54b5ea..1dde025 100644 --- a/bench/witchcraft/semigroup/tuple_bench.exs +++ b/bench/witchcraft/semigroup/tuple_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Semigroup.TupleBench do + @moduledoc false + use Benchfella use Witchcraft.Semigroup diff --git a/bench/witchcraft/semigroupoid/function_bench.exs b/bench/witchcraft/semigroupoid/function_bench.exs index b45aae0..4649230 100644 --- a/bench/witchcraft/semigroupoid/function_bench.exs +++ b/bench/witchcraft/semigroupoid/function_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Semigroupoid.FunctionBench do + @moduledoc false + use Benchfella use Witchcraft.Semigroupoid diff --git a/bench/witchcraft/setoid/bitstring_bench.exs b/bench/witchcraft/setoid/bitstring_bench.exs index 31d3007..0fa845b 100644 --- a/bench/witchcraft/setoid/bitstring_bench.exs +++ b/bench/witchcraft/setoid/bitstring_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Setoid.BitStringBench do + @moduledoc false + use Benchfella use Witchcraft.Setoid diff --git a/bench/witchcraft/setoid/float_bench.exs b/bench/witchcraft/setoid/float_bench.exs index 6bdff5e..81d0747 100644 --- a/bench/witchcraft/setoid/float_bench.exs +++ b/bench/witchcraft/setoid/float_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Setoid.FloatBench do + @moduledoc false + use Benchfella use Witchcraft.Setoid diff --git a/bench/witchcraft/setoid/integer_bench.exs b/bench/witchcraft/setoid/integer_bench.exs index ecffc50..08b7fae 100644 --- a/bench/witchcraft/setoid/integer_bench.exs +++ b/bench/witchcraft/setoid/integer_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Setoid.IntegerBench do + @moduledoc false + use Benchfella use Witchcraft.Setoid diff --git a/bench/witchcraft/setoid/list_bench.exs b/bench/witchcraft/setoid/list_bench.exs index c753577..ae95bf9 100644 --- a/bench/witchcraft/setoid/list_bench.exs +++ b/bench/witchcraft/setoid/list_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Setoid.ListBench do + @moduledoc false + use Benchfella use Witchcraft.Setoid diff --git a/bench/witchcraft/setoid/map_bench.exs b/bench/witchcraft/setoid/map_bench.exs index ba2e459..f633206 100644 --- a/bench/witchcraft/setoid/map_bench.exs +++ b/bench/witchcraft/setoid/map_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Setoid.MapBench do + @moduledoc false + use Benchfella use Witchcraft.Setoid diff --git a/bench/witchcraft/setoid/map_set_bench.exs b/bench/witchcraft/setoid/map_set_bench.exs index 92556d0..a206850 100644 --- a/bench/witchcraft/setoid/map_set_bench.exs +++ b/bench/witchcraft/setoid/map_set_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Setoid.MapSetBench do + @moduledoc false + use Benchfella use Witchcraft.Setoid diff --git a/bench/witchcraft/setoid/tuple_bench.exs b/bench/witchcraft/setoid/tuple_bench.exs index 746a130..07310b5 100644 --- a/bench/witchcraft/setoid/tuple_bench.exs +++ b/bench/witchcraft/setoid/tuple_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Setoid.TupleBench do + @moduledoc false + use Benchfella use Witchcraft.Setoid diff --git a/bench/witchcraft/traversable/list_bench.exs b/bench/witchcraft/traversable/list_bench.exs index 50b9382..645db26 100644 --- a/bench/witchcraft/traversable/list_bench.exs +++ b/bench/witchcraft/traversable/list_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Traversable.ListBench do + @moduledoc false + require Integer use Benchfella diff --git a/bench/witchcraft/traversable/tuple_bench.exs b/bench/witchcraft/traversable/tuple_bench.exs index e2b30f8..521e578 100644 --- a/bench/witchcraft/traversable/tuple_bench.exs +++ b/bench/witchcraft/traversable/tuple_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.Traversable.TupleBench do + @moduledoc false + require Integer use Benchfella diff --git a/bench/witchcraft/unit_bench.exs b/bench/witchcraft/unit_bench.exs index 65f64ec..b79d8aa 100644 --- a/bench/witchcraft/unit_bench.exs +++ b/bench/witchcraft/unit_bench.exs @@ -1,4 +1,6 @@ defmodule Witchcraft.UnitBench do + @moduledoc false + use Benchfella import Witchcraft.Unit From b325db9ccb50ea48e6f9d39b7becb48c3bdeb91c Mon Sep 17 00:00:00 2001 From: Vadim Tsvetkov Date: Sun, 19 Dec 2021 01:01:34 +0300 Subject: [PATCH 3/4] Run `mix format bench/**/*.exs` --- .../witchcraft/applicative/function_bench.exs | 7 +- bench/witchcraft/applicative/list_bench.exs | 5 +- bench/witchcraft/applicative/tuple_bench.exs | 5 +- bench/witchcraft/apply/function_bench.exs | 138 +++++++---- bench/witchcraft/apply/list_bench.exs | 154 +++++++------ bench/witchcraft/apply/tuple_bench.exs | 86 +++---- bench/witchcraft/arrow/function_bench.exs | 39 ++-- bench/witchcraft/bifunctor/tuple_bench.exs | 27 ++- bench/witchcraft/category/function_bench.exs | 5 +- bench/witchcraft/chain/function_bench.exs | 4 +- bench/witchcraft/comonad/tuple_bench.exs | 13 +- bench/witchcraft/extend/function_bench.exs | 19 +- bench/witchcraft/extend/list_bench.exs | 24 +- bench/witchcraft/extend/tuple_bench.exs | 20 +- bench/witchcraft/foldable/bitstring_bench.exs | 97 ++++---- bench/witchcraft/foldable/list_bench.exs | 211 +++++++++-------- bench/witchcraft/foldable/map_bench.exs | 218 ++++++++++-------- bench/witchcraft/foldable/tuple_bench.exs | 139 +++++------ bench/witchcraft/functor/function_bench.exs | 47 ++-- bench/witchcraft/functor/list_bench.exs | 33 ++- bench/witchcraft/functor/map_bench.exs | 36 +-- bench/witchcraft/functor/tuple_bench.exs | 33 ++- bench/witchcraft/monad/function_bench.exs | 17 +- bench/witchcraft/monad/list_bench.exs | 58 +++-- bench/witchcraft/monad/tuple_bench.exs | 57 +++-- bench/witchcraft/monoid/bitstring_bench.exs | 11 +- bench/witchcraft/monoid/float_bench.exs | 9 +- bench/witchcraft/monoid/function_bench.exs | 5 +- bench/witchcraft/monoid/integer_bench.exs | 9 +- bench/witchcraft/monoid/list_bench.exs | 9 +- bench/witchcraft/monoid/map_bench.exs | 13 +- bench/witchcraft/monoid/map_set_bench.exs | 9 +- bench/witchcraft/monoid/tuple_bench.exs | 9 +- bench/witchcraft/ord/bitstring.exs | 34 +-- bench/witchcraft/ord/float_bench.exs | 32 +-- bench/witchcraft/ord/integer_bench.exs | 32 +-- bench/witchcraft/ord/list_bench.exs | 34 +-- bench/witchcraft/ord/map_bench.exs | 34 +-- bench/witchcraft/ord/tuple_bench.exs | 34 +-- .../witchcraft/semigroup/bitstring_bench.exs | 17 +- bench/witchcraft/semigroup/float_bench.exs | 15 +- bench/witchcraft/semigroup/function_bench.exs | 15 +- bench/witchcraft/semigroup/integer_bench.exs | 15 +- bench/witchcraft/semigroup/list_bench.exs | 17 +- bench/witchcraft/semigroup/map_bench.exs | 17 +- bench/witchcraft/semigroup/mapset_bench 2.exs | 15 +- bench/witchcraft/semigroup/mapset_bench.exs | 15 +- bench/witchcraft/semigroup/tuple_bench.exs | 15 +- .../semigroupoid/function_bench.exs | 33 ++- bench/witchcraft/setoid/bitstring_bench.exs | 36 ++- bench/witchcraft/setoid/float_bench.exs | 20 +- bench/witchcraft/setoid/integer_bench.exs | 20 +- bench/witchcraft/setoid/list_bench.exs | 22 +- bench/witchcraft/setoid/map_bench.exs | 22 +- bench/witchcraft/setoid/map_set_bench.exs | 20 +- bench/witchcraft/setoid/tuple_bench.exs | 22 +- bench/witchcraft/traversable/list_bench.exs | 13 +- bench/witchcraft/traversable/tuple_bench.exs | 13 +- bench/witchcraft/unit_bench.exs | 6 +- 59 files changed, 1135 insertions(+), 999 deletions(-) diff --git a/bench/witchcraft/applicative/function_bench.exs b/bench/witchcraft/applicative/function_bench.exs index 7574d62..a1847a6 100644 --- a/bench/witchcraft/applicative/function_bench.exs +++ b/bench/witchcraft/applicative/function_bench.exs @@ -12,7 +12,7 @@ defmodule Witchcraft.Applicative.FunctionBench do # Data Types # # ---------- # - def fun(x), do: "#{inspect x}-#{inspect x}" + def fun(x), do: "#{inspect(x)}-#{inspect(x)}" # -------------- # # Test Functions # @@ -25,7 +25,6 @@ defmodule Witchcraft.Applicative.FunctionBench do # Applicative # ############### - bench "of/1", do: to_fun(42) - bench "of/2", do: of(&fun/1, &twice/1) - + bench("of/1", do: to_fun(42)) + bench("of/2", do: of(&fun/1, &twice/1)) end diff --git a/bench/witchcraft/applicative/list_bench.exs b/bench/witchcraft/applicative/list_bench.exs index a5b6a20..3722b69 100644 --- a/bench/witchcraft/applicative/list_bench.exs +++ b/bench/witchcraft/applicative/list_bench.exs @@ -25,7 +25,6 @@ defmodule Witchcraft.Applicative.ListBench do # Applicative # ############### - bench "of/1", do: to_list(@to_wrap) - bench "of/2", do: of(@list, @to_wrap) - + bench("of/1", do: to_list(@to_wrap)) + bench("of/2", do: of(@list, @to_wrap)) end diff --git a/bench/witchcraft/applicative/tuple_bench.exs b/bench/witchcraft/applicative/tuple_bench.exs index 4fd1f5f..f93b400 100644 --- a/bench/witchcraft/applicative/tuple_bench.exs +++ b/bench/witchcraft/applicative/tuple_bench.exs @@ -25,7 +25,6 @@ defmodule Witchcraft.Applicative.TupleBench do # Applicative # ############### - bench "of/1", do: to_tuple(@to_wrap) - bench "of/2", do: of(@tuple, @to_wrap) - + bench("of/1", do: to_tuple(@to_wrap)) + bench("of/2", do: of(@tuple, @to_wrap)) end diff --git a/bench/witchcraft/apply/function_bench.exs b/bench/witchcraft/apply/function_bench.exs index 8de13e3..84cbdbf 100644 --- a/bench/witchcraft/apply/function_bench.exs +++ b/bench/witchcraft/apply/function_bench.exs @@ -4,7 +4,6 @@ defmodule Witchcraft.Apply.FunBench do use Benchfella use Witchcraft.Apply - ######### # Setup # ######### @@ -18,7 +17,8 @@ defmodule Witchcraft.Apply.FunBench do defp slow_fun(z) do Process.sleep(20) - fn(x, y) -> + + fn x, y -> x + y * z end end @@ -36,56 +36,95 @@ defmodule Witchcraft.Apply.FunBench do # Data # # ==== # - bench "data convey/2", do: fn x -> fun(x) end |> convey(fn x -> fun(x) end) - bench "data ap/2", do: fn x -> fun(x) end |> ap(fn x -> fun(x) end) + bench("data convey/2", do: fn x -> fun(x) end |> convey(fn x -> fun(x) end)) + bench("data ap/2", do: fn x -> fun(x) end |> ap(fn x -> fun(x) end)) + + bench("data <<~/2", do: fn x -> fun(x) end <<~ fn x -> fun(x) end) + bench("data <<~/2", do: fn x -> fun(x) end <<~ fn x -> fun(x) end) + + bench("data ~>>/2", do: fn x -> fun(x) end ~>> fn x -> fun(x) end) + bench("data ~>>/2", do: fn x -> fun(x) end ~>> fn x -> fun(x) end) - bench "data <<~/2", do: fn x -> fun(x) end <<~ fn x -> fun(x) end - bench "data <<~/2", do: fn x -> fun(x) end <<~ fn x -> fun(x) end + bench("data provide/2", do: fn x -> fun(x) end |> provide(fn x -> fun(x) end)) + bench("data supply/2", do: fn x -> fun(x) end |> supply(fn x -> fun(x) end)) - bench "data ~>>/2", do: fn x -> fun(x) end ~>> fn x -> fun(x) end - bench "data ~>>/2", do: fn x -> fun(x) end ~>> fn x -> fun(x) end + bench("data lift/3", do: lift(fn x -> fun(x) end, fn x -> fun(x) end, &+/2)) - bench "data provide/2", do: fn x -> fun(x) end |> provide(fn x -> fun(x) end) - bench "data supply/2", do: fn x -> fun(x) end |> supply(fn x -> fun(x) end) + bench("data lift/4", + do: lift(fn x -> fun(x) end, fn x -> fun(x) end, fn x, y, z -> x + y + z end) + ) - bench "data lift/3", do: lift(fn x -> fun(x) end, fn x -> fun(x) end, &+/2) - bench "data lift/4", do: lift(fn x -> fun(x) end, fn x -> fun(x) end, fn(x, y, z) -> x + y + z end) - bench "data lift/5", do: lift(fn x -> fun(x) end, fn x -> fun(x) end, fn x -> fun(x) end, fn(w, x, y, z) -> w + x + y + z end) + bench("data lift/5", + do: + lift(fn x -> fun(x) end, fn x -> fun(x) end, fn x -> fun(x) end, fn w, x, y, z -> + w + x + y + z + end) + ) - bench "data over/3", do: over(&+/2, fn x -> fun(x) end, fn x -> fun(x) end) - bench "data over/4", do: over(fn(x, y, z) -> x + y + z end, fn x -> fun(x) end, fn x -> fun(x) end) - bench "data over/5", do: over(fn(w, x, y, z) -> w + x + y + z end, fn x -> fun(x) end, fn x -> fun(x) end, fn x -> fun(x) end) + bench("data over/3", do: over(&+/2, fn x -> fun(x) end, fn x -> fun(x) end)) - bench "following/2", do: fn x -> fun(x) end |> following(fn x -> fun(x) end) - bench "then/2", do: fn x -> fun(x) end |> then(fn x -> fun(x) end) + bench("data over/4", + do: over(fn x, y, z -> x + y + z end, fn x -> fun(x) end, fn x -> fun(x) end) + ) + + bench("data over/5", + do: + over(fn w, x, y, z -> w + x + y + z end, fn x -> fun(x) end, fn x -> fun(x) end, fn x -> + fun(x) + end) + ) + + bench("following/2", do: fn x -> fun(x) end |> following(fn x -> fun(x) end)) + bench("then/2", do: fn x -> fun(x) end |> then(fn x -> fun(x) end)) # ----- # # Async # # ----- # - bench "data async_convey/2", do: fn x -> fun(x) end |> async_convey(fn x -> fun(x) end) - bench "data async_ap/2", do: fn x -> fun(x) end |> async_ap(fn x -> fun(x) end) + bench("data async_convey/2", do: fn x -> fun(x) end |> async_convey(fn x -> fun(x) end)) + bench("data async_ap/2", do: fn x -> fun(x) end |> async_ap(fn x -> fun(x) end)) + + bench("async_lift/3", do: async_lift(fn x -> fun(x) end, fn x -> fun(x) end, &+/2)) - bench "async_lift/3", do: async_lift(fn x -> fun(x) end, fn x -> fun(x) end, &+/2) - bench "async_lift/4", do: async_lift(fn x -> fun(x) end, fn x -> fun(x) end, fn(x, y, z) -> x + y + z end) - bench "async_lift/5", do: async_lift(fn x -> fun(x) end, fn x -> fun(x) end, fn x -> fun(x) end, fn(w, x, y, z) -> w + x + y + z end) + bench("async_lift/4", + do: async_lift(fn x -> fun(x) end, fn x -> fun(x) end, fn x, y, z -> x + y + z end) + ) - bench "async_over/3", do: async_over(&+/2, fn x -> fun(x) end, fn x -> fun(x) end) - bench "async_over/4", do: async_over(fn(x, y, z) -> x + y + z end, fn x -> fun(x) end, fn x -> fun(x) end) - bench "async_over/5", do: async_over(fn(w, x, y, z) -> w + x + y + z end, fn x -> fun(x) end, fn x -> fun(x) end, fn x -> fun(x) end) + bench("async_lift/5", + do: + async_lift(fn x -> fun(x) end, fn x -> fun(x) end, fn x -> fun(x) end, fn w, x, y, z -> + w + x + y + z + end) + ) - bench "!!! convey/2", do: fn x -> fun(x) end |> convey(fn y -> slow_fun(y) end) - bench "!!! ap/2", do: fn y -> slow_fun(y) end |> ap(fn x -> fun(x) end) + bench("async_over/3", do: async_over(&+/2, fn x -> fun(x) end, fn x -> fun(x) end)) + + bench("async_over/4", + do: async_over(fn x, y, z -> x + y + z end, fn x -> fun(x) end, fn x -> fun(x) end) + ) + + bench("async_over/5", + do: + async_over( + fn w, x, y, z -> w + x + y + z end, + fn x -> fun(x) end, + fn x -> fun(x) end, + fn x -> fun(x) end + ) + ) + + bench("!!! convey/2", do: fn x -> fun(x) end |> convey(fn y -> slow_fun(y) end)) + bench("!!! ap/2", do: fn y -> slow_fun(y) end |> ap(fn x -> fun(x) end)) bench "!!! lift/3" do - lift(fn x -> fun(x) end, fn x -> fun(x) end, fn(x, y) -> + lift(fn x -> fun(x) end, fn x -> fun(x) end, fn x, y -> Process.sleep(20) x + y end) end bench "!!! lift/4" do - lift(fn x -> fun(x) end, fn x -> fun(x) end, fn x -> fun(x) end, fn(x, y, z) -> + lift(fn x -> fun(x) end, fn x -> fun(x) end, fn x -> fun(x) end, fn x, y, z -> Process.sleep(20) x + y + z end) @@ -94,14 +133,17 @@ defmodule Witchcraft.Apply.FunBench do # also very slow, due to exponential complexity of multiple fun dimensions # 50^4 = 6_250_000 items to process bench "!!! lift/5" do - lift(fn x -> fun(x) end, fn x -> fun(x) end, fn x -> fun(x) end, fn x -> fun(x) end, fn(w, x, y, z) -> + lift(fn x -> fun(x) end, fn x -> fun(x) end, fn x -> fun(x) end, fn x -> fun(x) end, fn w, + x, + y, + z -> Process.sleep(20) w + x + y + z end) end bench "!!! over/3" do - fn(x, y) -> + fn x, y -> Process.sleep(20) x + y end @@ -109,7 +151,7 @@ defmodule Witchcraft.Apply.FunBench do end bench "!!! over/4" do - fn(x, y, z) -> + fn x, y, z -> Process.sleep(20) x + y + z end @@ -118,39 +160,45 @@ defmodule Witchcraft.Apply.FunBench do # So slow bench "!!! over/5" do - fn(w, x, y, z) -> + fn w, x, y, z -> Process.sleep(20) w + x + y + z end |> over(fn x -> fun(x) end, fn x -> fun(x) end, fn x -> fun(x) end, fn x -> fun(x) end) end - bench "!!! async_convey/2", do: fn x -> fun(x) end |> async_convey(fn y -> slow_fun(y) end) - bench "!!! async_ap/2", do: fn y -> slow_fun(y) end |> async_ap(fn x -> fun(x) end) + bench("!!! async_convey/2", do: fn x -> fun(x) end |> async_convey(fn y -> slow_fun(y) end)) + bench("!!! async_ap/2", do: fn y -> slow_fun(y) end |> async_ap(fn x -> fun(x) end)) bench "!!! async_lift/3" do - async_lift(fn x -> fun(x) end, fn x -> fun(x) end, fn(x, y) -> + async_lift(fn x -> fun(x) end, fn x -> fun(x) end, fn x, y -> Process.sleep(20) x + y end) end bench "!!! async_lift/4" do - async_lift(fn x -> fun(x) end, fn x -> fun(x) end, fn x -> fun(x) end, fn(x, y, z) -> + async_lift(fn x -> fun(x) end, fn x -> fun(x) end, fn x -> fun(x) end, fn x, y, z -> Process.sleep(20) x + y + z end) end bench "!!! async_lift/5" do - async_lift(fn x -> fun(x) end, fn x -> fun(x) end, fn x -> fun(x) end, fn x -> fun(x) end, fn(w, x, y, z) -> - Process.sleep(20) - w + x + y + z - end) + async_lift( + fn x -> fun(x) end, + fn x -> fun(x) end, + fn x -> fun(x) end, + fn x -> fun(x) end, + fn w, x, y, z -> + Process.sleep(20) + w + x + y + z + end + ) end bench "!!! async_over/3" do - fn(x, y) -> + fn x, y -> Process.sleep(20) x + y end @@ -158,7 +206,7 @@ defmodule Witchcraft.Apply.FunBench do end bench "!!! async_over/4" do - fn(x, y, z) -> + fn x, y, z -> Process.sleep(20) x + y + z end @@ -166,7 +214,7 @@ defmodule Witchcraft.Apply.FunBench do end bench "!!! async_over/5" do - fn(w, x, y, z) -> + fn w, x, y, z -> Process.sleep(20) w + x + y + z end diff --git a/bench/witchcraft/apply/list_bench.exs b/bench/witchcraft/apply/list_bench.exs index b8fad1f..6d9b16e 100644 --- a/bench/witchcraft/apply/list_bench.exs +++ b/bench/witchcraft/apply/list_bench.exs @@ -20,7 +20,7 @@ defmodule Witchcraft.Apply.ListBench do end def fun_list_b do - @list_a |> replace(fn x -> "#{inspect x}-#{inspect x}" end) + @list_a |> replace(fn x -> "#{inspect(x)}-#{inspect(x)}" end) end def slow_fun_list_a do @@ -29,20 +29,17 @@ defmodule Witchcraft.Apply.ListBench do Process.sleep(20) x + 1 end, - fn x -> Process.sleep(20) x * 10 end, - fn x -> Process.sleep(20) x - 4 end, - fn x -> Process.sleep(20) - inspect x + inspect(x) end ] end @@ -50,7 +47,7 @@ defmodule Witchcraft.Apply.ListBench do def slow_fun_list_b do replace(@list_b, fn x -> Process.sleep(20) - "#{inspect x}-#{inspect x}" + "#{inspect(x)}-#{inspect(x)}" end) end @@ -62,49 +59,55 @@ defmodule Witchcraft.Apply.ListBench do # Data # # ==== # - bench "data convey/2", do: @list_a |> convey(fun_list_a()) - bench "data ap/2", do: fun_list_a() |> ap(@list_b) + bench("data convey/2", do: @list_a |> convey(fun_list_a())) + bench("data ap/2", do: fun_list_a() |> ap(@list_b)) - bench "data <<~/2", do: fun_list_a() <<~ @list_a - bench "data <<~/2", do: fun_list_a() <<~ @list_a + bench("data <<~/2", do: fun_list_a() <<~ @list_a) + bench("data <<~/2", do: fun_list_a() <<~ @list_a) - bench "data ~>>/2", do: @list_a ~>> fun_list_a() - bench "data ~>>/2", do: @list_a ~>> fun_list_a() + bench("data ~>>/2", do: @list_a ~>> fun_list_a()) + bench("data ~>>/2", do: @list_a ~>> fun_list_a()) - bench "data provide/2", do: fun_list_a() |> provide(@list_a) - bench "data supply/2", do: @list_a |> supply(fun_list_a()) + bench("data provide/2", do: fun_list_a() |> provide(@list_a)) + bench("data supply/2", do: @list_a |> supply(fun_list_a())) - bench "data lift/3", do: lift(@list_a, @list_a, &+/2) - bench "data lift/4", do: lift(@list_a, @list_a, fn(x, y, z) -> x + y + z end) - bench "data lift/5", do: lift(@list_a, @list_a, @list_a, fn(w, x, y, z) -> w + x + y + z end) + bench("data lift/3", do: lift(@list_a, @list_a, &+/2)) + bench("data lift/4", do: lift(@list_a, @list_a, fn x, y, z -> x + y + z end)) + bench("data lift/5", do: lift(@list_a, @list_a, @list_a, fn w, x, y, z -> w + x + y + z end)) - bench "data over/3", do: over(&+/2, @list_a, @list_a) - bench "data over/4", do: over(fn(x, y, z) -> x + y + z end, @list_a, @list_a) - bench "data over/5", do: over(fn(w, x, y, z) -> w + x + y + z end, @list_a, @list_a, @list_a) + bench("data over/3", do: over(&+/2, @list_a, @list_a)) + bench("data over/4", do: over(fn x, y, z -> x + y + z end, @list_a, @list_a)) + bench("data over/5", do: over(fn w, x, y, z -> w + x + y + z end, @list_a, @list_a, @list_a)) - bench "following/2", do: @list_a |> following(@list_a) - bench "then/2", do: @list_a |> then(@list_a) + bench("following/2", do: @list_a |> following(@list_a)) + bench("then/2", do: @list_a |> then(@list_a)) # ----- # # Async # # ----- # - bench "data async_convey/2", do: @list_a |> async_convey(fun_list_a()) - bench "data async_ap/2", do: fun_list_a() |> async_ap(@list_a) + bench("data async_convey/2", do: @list_a |> async_convey(fun_list_a())) + bench("data async_ap/2", do: fun_list_a() |> async_ap(@list_a)) + + bench("async_lift/3", do: async_lift(@list_a, @list_a, &+/2)) + bench("async_lift/4", do: async_lift(@list_a, @list_a, fn x, y, z -> x + y + z end)) - bench "async_lift/3", do: async_lift(@list_a, @list_a, &+/2) - bench "async_lift/4", do: async_lift(@list_a, @list_a, fn(x, y, z) -> x + y + z end) - bench "async_lift/5", do: async_lift(@list_a, @list_a, @list_a, fn(w, x, y, z) -> w + x + y + z end) + bench("async_lift/5", + do: async_lift(@list_a, @list_a, @list_a, fn w, x, y, z -> w + x + y + z end) + ) - bench "async_over/3", do: async_over(&+/2, @list_a, @list_a) - bench "async_over/4", do: async_over(fn(x, y, z) -> x + y + z end, @list_a, @list_a) - bench "async_over/5", do: async_over(fn(w, x, y, z) -> w + x + y + z end, @list_a, @list_a, @list_a) + bench("async_over/3", do: async_over(&+/2, @list_a, @list_a)) + bench("async_over/4", do: async_over(fn x, y, z -> x + y + z end, @list_a, @list_a)) - bench "!!! convey/2", do: @list_a |> convey(slow_fun_list_a()) - bench "!!! ap/2", do: slow_fun_list_a() |> ap(@list_a) + bench("async_over/5", + do: async_over(fn w, x, y, z -> w + x + y + z end, @list_a, @list_a, @list_a) + ) + + bench("!!! convey/2", do: @list_a |> convey(slow_fun_list_a())) + bench("!!! ap/2", do: slow_fun_list_a() |> ap(@list_a)) bench "!!! lift/3" do - lift(@list_a, @list_a, fn(x, y) -> + lift(@list_a, @list_a, fn x, y -> Process.sleep(20) x + y end) @@ -128,7 +131,7 @@ defmodule Witchcraft.Apply.ListBench do # end bench "!!! over/3" do - fn(x, y) -> + fn x, y -> Process.sleep(20) x + y end @@ -153,32 +156,32 @@ defmodule Witchcraft.Apply.ListBench do # |> over(@list_a, @list_a, @list_a, @list_a) # end - bench "!!! async_convey/2", do: @list_a |> async_convey(slow_fun_list_a()) - bench "!!! async_ap/2", do: slow_fun_list_a() |> async_ap(@list_a) + bench("!!! async_convey/2", do: @list_a |> async_convey(slow_fun_list_a())) + bench("!!! async_ap/2", do: slow_fun_list_a() |> async_ap(@list_a)) bench "!!! async_lift/3" do - async_lift(@list_a, @list_a, fn(x, y) -> + async_lift(@list_a, @list_a, fn x, y -> Process.sleep(20) x + y end) end bench "!!! async_lift/4" do - async_lift(@list_a, @list_a, @list_a, fn(x, y, z) -> + async_lift(@list_a, @list_a, @list_a, fn x, y, z -> Process.sleep(20) x + y + z end) end bench "!!! async_lift/5" do - async_lift(@list_a, @list_a, @list_a, @list_a, fn(w, x, y, z) -> + async_lift(@list_a, @list_a, @list_a, @list_a, fn w, x, y, z -> Process.sleep(20) w + x + y + z end) end bench "!!! async_over/3" do - fn(x, y) -> + fn x, y -> Process.sleep(20) x + y end @@ -186,7 +189,7 @@ defmodule Witchcraft.Apply.ListBench do end bench "!!! async_over/4" do - fn(x, y, z) -> + fn x, y, z -> Process.sleep(20) x + y + z end @@ -194,7 +197,7 @@ defmodule Witchcraft.Apply.ListBench do end bench "!!! async_over/5" do - fn(w, x, y, z) -> + fn w, x, y, z -> Process.sleep(20) w + x + y + z end @@ -205,41 +208,47 @@ defmodule Witchcraft.Apply.ListBench do # Funs # # ==== # - bench "funs convey/2", do: @list_b |> convey(fun_list_b()) - bench "funs ap/2", do: fun_list_b() |> ap(@list_b) + bench("funs convey/2", do: @list_b |> convey(fun_list_b())) + bench("funs ap/2", do: fun_list_b() |> ap(@list_b)) - bench "funs <<~/2", do: fun_list_b() <<~ @list_b - bench "funs <<~/2", do: fun_list_b() <<~ @list_b + bench("funs <<~/2", do: fun_list_b() <<~ @list_b) + bench("funs <<~/2", do: fun_list_b() <<~ @list_b) - bench "funs ~>>/2", do: @list_b ~>> fun_list_b() - bench "funs ~>>/2", do: @list_b ~>> fun_list_b() + bench("funs ~>>/2", do: @list_b ~>> fun_list_b()) + bench("funs ~>>/2", do: @list_b ~>> fun_list_b()) - bench "funs provide/2", do: fun_list_b() |> provide(@list_b) - bench "funs supply/2", do: @list_b |> supply(fun_list_b()) + bench("funs provide/2", do: fun_list_b() |> provide(@list_b)) + bench("funs supply/2", do: @list_b |> supply(fun_list_b())) - bench "following/2", do: @list_b |> following(@list_b) - bench "then/2", do: @list_b |> then(@list_b) + bench("following/2", do: @list_b |> following(@list_b)) + bench("then/2", do: @list_b |> then(@list_b)) # ----- # # Async # # ----- # - bench "funs async_convey/2", do: @list_b |> async_convey(fun_list_b()) - bench "funs async_ap/2", do: fun_list_b() |> async_ap(@list_b) + bench("funs async_convey/2", do: @list_b |> async_convey(fun_list_b())) + bench("funs async_ap/2", do: fun_list_b() |> async_ap(@list_b)) + + bench("funs async_lift/3", do: async_lift(@list_b, @list_b, &+/2)) + bench("funs async_lift/4", do: async_lift(@list_b, @list_b, fn x, y, z -> x + y + z end)) - bench "funs async_lift/3", do: async_lift(@list_b, @list_b, &+/2) - bench "funs async_lift/4", do: async_lift(@list_b, @list_b, fn(x, y, z) -> x + y + z end) - bench "funs async_lift/5", do: async_lift(@list_b, @list_b, @list_b, fn(w, x, y, z) -> w + x + y + z end) + bench("funs async_lift/5", + do: async_lift(@list_b, @list_b, @list_b, fn w, x, y, z -> w + x + y + z end) + ) - bench "funs async_over/3", do: async_over(&+/2, @list_b, @list_b) - bench "funs async_over/4", do: async_over(fn(x, y, z) -> x + y + z end, @list_b, @list_b) - bench "funs async_over/5", do: async_over(fn(w, x, y, z) -> w + x + y + z end, @list_b, @list_b, @list_b) + bench("funs async_over/3", do: async_over(&+/2, @list_b, @list_b)) + bench("funs async_over/4", do: async_over(fn x, y, z -> x + y + z end, @list_b, @list_b)) - bench "!!! convey/2", do: @list_b |> convey(slow_fun_list_b()) - bench "!!! ap/2", do: slow_fun_list_b() |> ap(@list_b) + bench("funs async_over/5", + do: async_over(fn w, x, y, z -> w + x + y + z end, @list_b, @list_b, @list_b) + ) + + bench("!!! convey/2", do: @list_b |> convey(slow_fun_list_b())) + bench("!!! ap/2", do: slow_fun_list_b() |> ap(@list_b)) bench "!!! funs lift/3" do - lift(@list_b, @list_b, fn(x, y) -> + lift(@list_b, @list_b, fn x, y -> Process.sleep(20) x + y end) @@ -264,7 +273,7 @@ defmodule Witchcraft.Apply.ListBench do # end bench "!!! funs over/3" do - fn(x, y) -> + fn x, y -> Process.sleep(20) x + y end @@ -289,32 +298,32 @@ defmodule Witchcraft.Apply.ListBench do # |> over(@list_b, @list_b, @list_b, @list_b) # end - bench "!!! funs async_convey/2", do: @list_b |> async_convey(slow_fun_list_b()) - bench "!!! funs async_ap/2", do: slow_fun_list_b() |> async_ap(@list_b) + bench("!!! funs async_convey/2", do: @list_b |> async_convey(slow_fun_list_b())) + bench("!!! funs async_ap/2", do: slow_fun_list_b() |> async_ap(@list_b)) bench "!!! funs async_lift/3" do - async_lift(@list_b, @list_b, fn(x, y) -> + async_lift(@list_b, @list_b, fn x, y -> Process.sleep(20) x + y end) end bench "!!! funs async_lift/4" do - async_lift(@list_b, @list_b, @list_b, fn(x, y, z) -> + async_lift(@list_b, @list_b, @list_b, fn x, y, z -> Process.sleep(20) x + y + z end) end bench "!!! funs async_lift/5" do - async_lift(@list_b, @list_b, @list_b, @list_b, fn(w, x, y, z) -> + async_lift(@list_b, @list_b, @list_b, @list_b, fn w, x, y, z -> Process.sleep(20) w + x + y + z end) end bench "!!! funs async_over/3" do - fn(x, y) -> + fn x, y -> Process.sleep(20) x + y end @@ -322,7 +331,7 @@ defmodule Witchcraft.Apply.ListBench do end bench "!!! funs async_over/4" do - fn(x, y, z) -> + fn x, y, z -> Process.sleep(20) x + y + z end @@ -330,11 +339,10 @@ defmodule Witchcraft.Apply.ListBench do end bench "!!! funs async_over/5" do - fn(w, x, y, z) -> + fn w, x, y, z -> Process.sleep(20) w + x + y + z end |> async_over(@list_b, @list_b, @list_b, @list_b) end - end diff --git a/bench/witchcraft/apply/tuple_bench.exs b/bench/witchcraft/apply/tuple_bench.exs index 5b3e72e..dace9d0 100644 --- a/bench/witchcraft/apply/tuple_bench.exs +++ b/bench/witchcraft/apply/tuple_bench.exs @@ -15,13 +15,13 @@ defmodule Witchcraft.Apply.TupleBench do @tuple 0..10 |> Enum.to_list() |> Enum.shuffle() |> List.to_tuple() def fun_tuple do - @tuple |> replace(fn x -> "#{inspect x}-#{inspect x}" end) + @tuple |> replace(fn x -> "#{inspect(x)}-#{inspect(x)}" end) end def slow_fun_tuple do replace(@tuple, fn x -> Process.sleep(20) - "#{inspect x}-#{inspect x}" + "#{inspect(x)}-#{inspect(x)}" end) end @@ -33,56 +33,58 @@ defmodule Witchcraft.Apply.TupleBench do # Data # # ==== # - bench "data convey/2", do: @tuple |> convey(fun_tuple()) - bench "data ap/2", do: fun_tuple() |> ap(@tuple) + bench("data convey/2", do: @tuple |> convey(fun_tuple())) + bench("data ap/2", do: fun_tuple() |> ap(@tuple)) - bench "data <<~/2", do: fun_tuple() <<~ @tuple - bench "data <<~/2", do: fun_tuple() <<~ @tuple + bench("data <<~/2", do: fun_tuple() <<~ @tuple) + bench("data <<~/2", do: fun_tuple() <<~ @tuple) - bench "data ~>>/2", do: @tuple ~>> fun_tuple() - bench "data ~>>/2", do: @tuple ~>> fun_tuple() + bench("data ~>>/2", do: @tuple ~>> fun_tuple()) + bench("data ~>>/2", do: @tuple ~>> fun_tuple()) - bench "data provide/2", do: fun_tuple() |> provide(@tuple) - bench "data supply/2", do: @tuple |> supply(fun_tuple()) + bench("data provide/2", do: fun_tuple() |> provide(@tuple)) + bench("data supply/2", do: @tuple |> supply(fun_tuple())) - bench "data lift/3", do: lift(@tuple, @tuple, &+/2) - bench "data lift/4", do: lift(@tuple, @tuple, fn(x, y, z) -> x + y + z end) - bench "data lift/5", do: lift(@tuple, @tuple, @tuple, fn(w, x, y, z) -> w + x + y + z end) + bench("data lift/3", do: lift(@tuple, @tuple, &+/2)) + bench("data lift/4", do: lift(@tuple, @tuple, fn x, y, z -> x + y + z end)) + bench("data lift/5", do: lift(@tuple, @tuple, @tuple, fn w, x, y, z -> w + x + y + z end)) - bench "data over/3", do: over(&+/2, @tuple, @tuple) - bench "data over/4", do: over(fn(x, y, z) -> x + y + z end, @tuple, @tuple) - bench "data over/5", do: over(fn(w, x, y, z) -> w + x + y + z end, @tuple, @tuple, @tuple) + bench("data over/3", do: over(&+/2, @tuple, @tuple)) + bench("data over/4", do: over(fn x, y, z -> x + y + z end, @tuple, @tuple)) + bench("data over/5", do: over(fn w, x, y, z -> w + x + y + z end, @tuple, @tuple, @tuple)) - bench "following/2", do: @tuple |> following(@tuple) - bench "then/2", do: @tuple |> then(@tuple) + bench("following/2", do: @tuple |> following(@tuple)) + bench("then/2", do: @tuple |> then(@tuple)) # ----- # # Async # # ----- # - bench "data async_convey/2", do: @tuple |> async_convey(fun_tuple()) - bench "data async_ap/2", do: fun_tuple() |> async_ap(@tuple) + bench("data async_convey/2", do: @tuple |> async_convey(fun_tuple())) + bench("data async_ap/2", do: fun_tuple() |> async_ap(@tuple)) - bench "async_lift/3", do: async_lift(@tuple, @tuple, &+/2) - bench "async_lift/4", do: async_lift(@tuple, @tuple, fn(x, y, z) -> x + y + z end) - bench "async_lift/5", do: async_lift(@tuple, @tuple, @tuple, fn(w, x, y, z) -> w + x + y + z end) + bench("async_lift/3", do: async_lift(@tuple, @tuple, &+/2)) + bench("async_lift/4", do: async_lift(@tuple, @tuple, fn x, y, z -> x + y + z end)) - bench "async_over/3", do: async_over(&+/2, @tuple, @tuple) - bench "async_over/4", do: async_over(fn(x, y, z) -> x + y + z end, @tuple, @tuple) - bench "async_over/5", do: async_over(fn(w, x, y, z) -> w + x + y + z end, @tuple, @tuple, @tuple) + bench("async_lift/5", do: async_lift(@tuple, @tuple, @tuple, fn w, x, y, z -> w + x + y + z end)) - bench "!!! convey/2", do: @tuple |> convey(slow_fun_tuple()) - bench "!!! ap/2", do: slow_fun_tuple() |> ap(@tuple) + bench("async_over/3", do: async_over(&+/2, @tuple, @tuple)) + bench("async_over/4", do: async_over(fn x, y, z -> x + y + z end, @tuple, @tuple)) + + bench("async_over/5", do: async_over(fn w, x, y, z -> w + x + y + z end, @tuple, @tuple, @tuple)) + + bench("!!! convey/2", do: @tuple |> convey(slow_fun_tuple())) + bench("!!! ap/2", do: slow_fun_tuple() |> ap(@tuple)) bench "!!! lift/3" do - lift(@tuple, @tuple, fn(x, y) -> + lift(@tuple, @tuple, fn x, y -> Process.sleep(20) x + y end) end bench "!!! lift/4" do - lift(@tuple, @tuple, @tuple, fn(x, y, z) -> + lift(@tuple, @tuple, @tuple, fn x, y, z -> Process.sleep(20) x + y + z end) @@ -91,14 +93,14 @@ defmodule Witchcraft.Apply.TupleBench do # also very slow, due to exponential complexity of multiple tuple dimensions # 50^4 = 6_250_000 items to process bench "!!! lift/5" do - lift(@tuple, @tuple, @tuple, @tuple, fn(w, x, y, z) -> + lift(@tuple, @tuple, @tuple, @tuple, fn w, x, y, z -> Process.sleep(20) w + x + y + z end) end bench "!!! over/3" do - fn(x, y) -> + fn x, y -> Process.sleep(20) x + y end @@ -106,7 +108,7 @@ defmodule Witchcraft.Apply.TupleBench do end bench "!!! over/4" do - fn(x, y, z) -> + fn x, y, z -> Process.sleep(20) x + y + z end @@ -115,39 +117,39 @@ defmodule Witchcraft.Apply.TupleBench do # So slow bench "!!! over/5" do - fn(w, x, y, z) -> + fn w, x, y, z -> Process.sleep(20) w + x + y + z end |> over(@tuple, @tuple, @tuple, @tuple) end - bench "!!! async_convey/2", do: @tuple |> async_convey(slow_fun_tuple()) - bench "!!! async_ap/2", do: slow_fun_tuple() |> async_ap(@tuple) + bench("!!! async_convey/2", do: @tuple |> async_convey(slow_fun_tuple())) + bench("!!! async_ap/2", do: slow_fun_tuple() |> async_ap(@tuple)) bench "!!! async_lift/3" do - async_lift(@tuple, @tuple, fn(x, y) -> + async_lift(@tuple, @tuple, fn x, y -> Process.sleep(20) x + y end) end bench "!!! async_lift/4" do - async_lift(@tuple, @tuple, @tuple, fn(x, y, z) -> + async_lift(@tuple, @tuple, @tuple, fn x, y, z -> Process.sleep(20) x + y + z end) end bench "!!! async_lift/5" do - async_lift(@tuple, @tuple, @tuple, @tuple, fn(w, x, y, z) -> + async_lift(@tuple, @tuple, @tuple, @tuple, fn w, x, y, z -> Process.sleep(20) w + x + y + z end) end bench "!!! async_over/3" do - fn(x, y) -> + fn x, y -> Process.sleep(20) x + y end @@ -155,7 +157,7 @@ defmodule Witchcraft.Apply.TupleBench do end bench "!!! async_over/4" do - fn(x, y, z) -> + fn x, y, z -> Process.sleep(20) x + y + z end @@ -163,7 +165,7 @@ defmodule Witchcraft.Apply.TupleBench do end bench "!!! async_over/5" do - fn(w, x, y, z) -> + fn w, x, y, z -> Process.sleep(20) w + x + y + z end diff --git a/bench/witchcraft/arrow/function_bench.exs b/bench/witchcraft/arrow/function_bench.exs index 76c15d5..687f4f3 100644 --- a/bench/witchcraft/arrow/function_bench.exs +++ b/bench/witchcraft/arrow/function_bench.exs @@ -15,41 +15,40 @@ defmodule Witchcraft.Arrow.FunctionBench do @single "data" @tuple {32, "1955?!"} - defp f(x), do: "#{inspect x}/#{inspect x}" - defp g(y), do: "#{inspect y}-#{inspect y}-#{inspect y}" + defp f(x), do: "#{inspect(x)}/#{inspect(x)}" + defp g(y), do: "#{inspect(y)}-#{inspect(y)}-#{inspect(y)}" ######### # Arrow # ######### - bench "arrowize/2", do: arrowize(&f/1, &g/1) - bench "id_arrow/1", do: id_arrow(&+/2) + bench("arrowize/2", do: arrowize(&f/1, &g/1)) + bench("id_arrow/1", do: id_arrow(&+/2)) - bench "precompose/2", do: precompose(&g/1, &f/1) - bench "postcompose/2", do: postcompose(&f/1, &g/1) + bench("precompose/2", do: precompose(&g/1, &f/1)) + bench("postcompose/2", do: postcompose(&f/1, &g/1)) - bench "first/1", do: first(&f/1) - bench "second/1", do: second(&f/1) + bench("first/1", do: first(&f/1)) + bench("second/1", do: second(&f/1)) - bench "apply first/1", do: first(&f/1).(@tuple) - bench "apply second/1", do: second(&f/1).(@tuple) + bench("apply first/1", do: first(&f/1).(@tuple)) + bench("apply second/1", do: second(&f/1).(@tuple)) - bench "product/2", do: product(&f/1, &g/1) - bench "fanout/2", do: fanout(&f/1, &g/1) + bench("product/2", do: product(&f/1, &g/1)) + bench("fanout/2", do: fanout(&f/1, &g/1)) - bench "apply product/2", do: product(&f/1, &g/1).(@tuple) - bench "apply fanout/2", do: fanout(&f/1, &g/1).(@single) + bench("apply product/2", do: product(&f/1, &g/1).(@tuple)) + bench("apply fanout/2", do: fanout(&f/1, &g/1).(@single)) # ---------------- # # Tuple Operations # # ---------------- # - bench "swap/1", do: swap({1, 2}) + bench("swap/1", do: swap({1, 2})) - bench "split/1", do: split(42) - bench "unsplit/1", do: unsplit({42, 42}, &+/2) - - bench "left reassociate/1", do: ({1, {2, 3}}) - bench "right reassociate/1", do: ({{1, 2}, 3}) + bench("split/1", do: split(42)) + bench("unsplit/1", do: unsplit({42, 42}, &+/2)) + bench("left reassociate/1", do: {1, {2, 3}}) + bench("right reassociate/1", do: {{1, 2}, 3}) end diff --git a/bench/witchcraft/bifunctor/tuple_bench.exs b/bench/witchcraft/bifunctor/tuple_bench.exs index 09219f4..460bb7e 100644 --- a/bench/witchcraft/bifunctor/tuple_bench.exs +++ b/bench/witchcraft/bifunctor/tuple_bench.exs @@ -18,20 +18,20 @@ defmodule Witchcraft.Bifunctor.TupleBench do # Test Functions # # -------------- # - defp add_one(x), do: x + 1 + defp add_one(x), do: x + 1 defp times_ten(y), do: y * 10 ########### # Comonad # ########### - bench "bimap/3", do: bimap(@tuple, &add_one/1, ×_ten/1) - bench "map_first/2", do: map_first(@tuple, &add_one/1) - bench "map_second/2", do: map_second(@tuple, &add_one/1) + bench("bimap/3", do: bimap(@tuple, &add_one/1, ×_ten/1)) + bench("map_first/2", do: map_first(@tuple, &add_one/1)) + bench("map_second/2", do: map_second(@tuple, &add_one/1)) - bench "bilift/3", do: bilift(@tuple, &add_one/1, ×_ten/1) - bench "lift_first/2", do: lift_first(@tuple, &add_one/1) - bench "lift_second/2", do: lift_second(@tuple, &add_one/1) + bench("bilift/3", do: bilift(@tuple, &add_one/1, ×_ten/1)) + bench("lift_first/2", do: lift_first(@tuple, &add_one/1)) + bench("lift_second/2", do: lift_second(@tuple, &add_one/1)) # ---------- # # Large Data # @@ -39,12 +39,11 @@ defmodule Witchcraft.Bifunctor.TupleBench do @big_tuple 0..100_000 |> Enum.to_list() |> Enum.shuffle() |> List.to_tuple() - bench "$$$ bimap/3", do: bimap(@big_tuple, &add_one/1, ×_ten/1) - bench "$$$ map_first/2", do: map_first(@big_tuple, &add_one/1) - bench "$$$ map_second/2", do: map_second(@big_tuple, &add_one/1) - - bench "$$$ bilift/3", do: bilift(@big_tuple, &add_one/1, ×_ten/1) - bench "$$$ lift_first/2", do: lift_first(@big_tuple, &add_one/1) - bench "$$$ lift_second/2", do: lift_second(@big_tuple, &add_one/1) + bench("$$$ bimap/3", do: bimap(@big_tuple, &add_one/1, ×_ten/1)) + bench("$$$ map_first/2", do: map_first(@big_tuple, &add_one/1)) + bench("$$$ map_second/2", do: map_second(@big_tuple, &add_one/1)) + bench("$$$ bilift/3", do: bilift(@big_tuple, &add_one/1, ×_ten/1)) + bench("$$$ lift_first/2", do: lift_first(@big_tuple, &add_one/1)) + bench("$$$ lift_second/2", do: lift_second(@big_tuple, &add_one/1)) end diff --git a/bench/witchcraft/category/function_bench.exs b/bench/witchcraft/category/function_bench.exs index 22248b3..0166b7d 100644 --- a/bench/witchcraft/category/function_bench.exs +++ b/bench/witchcraft/category/function_bench.exs @@ -12,12 +12,11 @@ defmodule Witchcraft.Category.FunctionBench do # Data Types # # ---------- # - defp f(x), do: "#{inspect x}/#{inspect x}" + defp f(x), do: "#{inspect(x)}/#{inspect(x)}" ################ # Semigroupoid # ################ - bench "identity/1", do: identity(&f/1) - + bench("identity/1", do: identity(&f/1)) end diff --git a/bench/witchcraft/chain/function_bench.exs b/bench/witchcraft/chain/function_bench.exs index 4afaae7..7df26cf 100644 --- a/bench/witchcraft/chain/function_bench.exs +++ b/bench/witchcraft/chain/function_bench.exs @@ -12,8 +12,8 @@ defmodule Witchcraft.Chain.FunctionBench do # Data Types # # ---------- # - def fun_a(x), do: "#{inspect x}-#{inspect x}" - def fun_b(y), do: "#{inspect y}!#{inspect y}" + def fun_a(x), do: "#{inspect(x)}-#{inspect(x)}" + def fun_b(y), do: "#{inspect(y)}!#{inspect(y)}" ######### # Chain # diff --git a/bench/witchcraft/comonad/tuple_bench.exs b/bench/witchcraft/comonad/tuple_bench.exs index be978b4..5d095ae 100644 --- a/bench/witchcraft/comonad/tuple_bench.exs +++ b/bench/witchcraft/comonad/tuple_bench.exs @@ -12,20 +12,23 @@ defmodule Witchcraft.Comonad.TupleBench do # Data Types # # ---------- # - @tuple 11..100 |> Enum.to_list() |> Enum.map(&({&1, &1})) |> Enum.shuffle() |> List.to_tuple() + @tuple 11..100 |> Enum.to_list() |> Enum.map(&{&1, &1}) |> Enum.shuffle() |> List.to_tuple() ########### # Comonad # ########### - bench "extract/1", do: extract(@tuple) + bench("extract/1", do: extract(@tuple)) # ---------- # # Large Data # # ---------- # - @big_tuple 0..100_000 |> Enum.to_list() |> Enum.map(&({&1, &1})) |> Enum.shuffle() |> List.to_tuple() - - bench "$$$ extract/1", do: extract(@big_tuple) + @big_tuple 0..100_000 + |> Enum.to_list() + |> Enum.map(&{&1, &1}) + |> Enum.shuffle() + |> List.to_tuple() + bench("$$$ extract/1", do: extract(@big_tuple)) end diff --git a/bench/witchcraft/extend/function_bench.exs b/bench/witchcraft/extend/function_bench.exs index 3323ce7..0200cb7 100644 --- a/bench/witchcraft/extend/function_bench.exs +++ b/bench/witchcraft/extend/function_bench.exs @@ -13,24 +13,24 @@ defmodule Witchcraft.Extend.FunctionBench do # Data Types # # ---------- # - defp fun(x), do: x + 1 - defp twice(f), do: f <|> f + defp fun(x), do: x + 1 + defp twice(f), do: f <|> f defp thrice(f), do: f <|> f <|> f ########## # Extend # ########## - bench "nest/1", do: nest(&fun/1) + bench("nest/1", do: nest(&fun/1)) - bench "extend/2", do: extend(&fun/1, &twice/1) - bench "curried_extend/2", do: curried_extend(&fun/1, &twice/1) + bench("extend/2", do: extend(&fun/1, &twice/1)) + bench("curried_extend/2", do: curried_extend(&fun/1, &twice/1)) - bench "peel/2", do: peel(&twice/1, &fun/1) - bench "curried_peel/2", do: curried_peel(&twice/1, &fun/1) + bench("peel/2", do: peel(&twice/1, &fun/1)) + bench("curried_peel/2", do: curried_peel(&twice/1, &fun/1)) - bench "compose_colink/2", do: compose_colink(&twice/1, &thrice/1) - bench "pipe_compose_colink/2", do: pipe_compose_colink(&thrice/1, &twice/1) + bench("compose_colink/2", do: compose_colink(&twice/1, &thrice/1)) + bench("pipe_compose_colink/2", do: pipe_compose_colink(&thrice/1, &twice/1)) bench "apply compose_colink/2" do both = compose_colink(&twice/1, &thrice/1) @@ -41,5 +41,4 @@ defmodule Witchcraft.Extend.FunctionBench do both = pipe_compose_colink(&thrice/1, &twice/1) extend(&fun/1, both) end - end diff --git a/bench/witchcraft/extend/list_bench.exs b/bench/witchcraft/extend/list_bench.exs index 3eea1ab..4ac0faa 100644 --- a/bench/witchcraft/extend/list_bench.exs +++ b/bench/witchcraft/extend/list_bench.exs @@ -18,16 +18,19 @@ defmodule Witchcraft.Extend.ListBench do # Extend # ########## - bench "nest/1", do: nest(@list) + bench("nest/1", do: nest(@list)) - bench "extend/2", do: extend(@list, fn [x | _] -> x + 1 end) - bench "curried_extend/2", do: curried_extend(@list, fn [x | _] -> x + 1 end) + bench("extend/2", do: extend(@list, fn [x | _] -> x + 1 end)) + bench("curried_extend/2", do: curried_extend(@list, fn [x | _] -> x + 1 end)) - bench "peel/2", do: peel(fn [x | _] -> x + 1 end, @list) - bench "curried_peel/2", do: curried_peel(fn [x | _] -> x + 1 end, @list) + bench("peel/2", do: peel(fn [x | _] -> x + 1 end, @list)) + bench("curried_peel/2", do: curried_peel(fn [x | _] -> x + 1 end, @list)) - bench "compose_colink/2", do: compose_colink(fn [x | _] -> x + 1 end, fn [y | _] -> y * 10 end) - bench "pipe_compose_colink/2", do: pipe_compose_colink(fn [y | _] -> y * 10 end, fn [x | _] -> x + 1 end) + bench("compose_colink/2", do: compose_colink(fn [x | _] -> x + 1 end, fn [y | _] -> y * 10 end)) + + bench("pipe_compose_colink/2", + do: pipe_compose_colink(fn [y | _] -> y * 10 end, fn [x | _] -> x + 1 end) + ) bench "apply compose_colink/2" do both = compose_colink(fn [x | _] -> x + 1 end, fn [y | _] -> y * 10 end) @@ -45,9 +48,8 @@ defmodule Witchcraft.Extend.ListBench do @big_list 0..100_000 |> Enum.to_list() - bench "$$$ nest/1", do: nest(@big_list) - - bench "$$$ extend/2", do: extend(@big_list, fn [x | _] -> x + 1 end) - bench "$$$ curried_extend/2", do: curried_extend(@big_list, fn [x | _] -> x + 1 end) + bench("$$$ nest/1", do: nest(@big_list)) + bench("$$$ extend/2", do: extend(@big_list, fn [x | _] -> x + 1 end)) + bench("$$$ curried_extend/2", do: curried_extend(@big_list, fn [x | _] -> x + 1 end)) end diff --git a/bench/witchcraft/extend/tuple_bench.exs b/bench/witchcraft/extend/tuple_bench.exs index c14755b..fdb86e7 100644 --- a/bench/witchcraft/extend/tuple_bench.exs +++ b/bench/witchcraft/extend/tuple_bench.exs @@ -18,16 +18,21 @@ defmodule Witchcraft.Extend.TupleBench do # Extend # ########## - bench "nest/1", do: nest(@tuple) + bench("nest/1", do: nest(@tuple)) - bench "extend/2", do: extend(@tuple, fn t -> elem(t, 0) + 1 end) - bench "curried_extend/2", do: curried_extend(@tuple, fn t -> elem(t, 0) + 1 end) + bench("extend/2", do: extend(@tuple, fn t -> elem(t, 0) + 1 end)) + bench("curried_extend/2", do: curried_extend(@tuple, fn t -> elem(t, 0) + 1 end)) - bench "peel/2", do: peel(fn t -> elem(t, 0) + 1 end, @tuple) - bench "curried_peel/2", do: curried_peel(fn t -> elem(t, 0) + 1 end, @tuple) + bench("peel/2", do: peel(fn t -> elem(t, 0) + 1 end, @tuple)) + bench("curried_peel/2", do: curried_peel(fn t -> elem(t, 0) + 1 end, @tuple)) - bench "compose_colink/2", do: compose_colink(fn t -> elem(t, 0) + 1 end, fn t -> elem(t, 1) * 10 end) - bench "pipe_compose_colink/2", do: pipe_compose_colink(fn t -> elem(t, 0) * 10 end, fn t -> elem(t, 2) + 1 end) + bench("compose_colink/2", + do: compose_colink(fn t -> elem(t, 0) + 1 end, fn t -> elem(t, 1) * 10 end) + ) + + bench("pipe_compose_colink/2", + do: pipe_compose_colink(fn t -> elem(t, 0) * 10 end, fn t -> elem(t, 2) + 1 end) + ) bench "apply compose_colink/2" do both = compose_colink(fn t -> elem(t, 0) + 1 end, fn t -> elem(t, 1) * 10 end) @@ -38,5 +43,4 @@ defmodule Witchcraft.Extend.TupleBench do both = pipe_compose_colink(fn t -> elem(t, 1) * 10 end, fn t -> elem(t, 0) + 1 end) extend(@tuple, both) end - end diff --git a/bench/witchcraft/foldable/bitstring_bench.exs b/bench/witchcraft/foldable/bitstring_bench.exs index 069bfe1..80101a5 100644 --- a/bench/witchcraft/foldable/bitstring_bench.exs +++ b/bench/witchcraft/foldable/bitstring_bench.exs @@ -21,45 +21,46 @@ defmodule Witchcraft.Foldable.BitStringBench do # Foldable # ############ - bench "flat_map/2", do: flat_map(@string, fn x -> [x, x <> x] end) + bench("flat_map/2", do: flat_map(@string, fn x -> [x, x <> x] end)) - bench "Kernel.string_size/1", do: String.length(@string) + bench("Kernel.string_size/1", do: String.length(@string)) - bench "count/1", do: count(@string) - bench "length/1", do: length(@string) + bench("count/1", do: count(@string)) + bench("length/1", do: length(@string)) - bench "empty?/1", do: empty?(@string) - bench "null?/1", do: null?(@string) + bench("empty?/1", do: empty?(@string)) + bench("null?/1", do: null?(@string)) - bench "member?/2", do: member?(@string, 99) + bench("member?/2", do: member?(@string, 99)) - bench "max/1", do: max(@string) - bench "max/2", do: max(@string, by: fn(x, y) -> Integer.mod(x, 3) > y end) + bench("max/1", do: max(@string)) + bench("max/2", do: max(@string, by: fn x, y -> Integer.mod(x, 3) > y end)) - bench "min/1", do: min(@string) - bench "min/2", do: min(@string, by: fn(x, y) -> Integer.mod(x, 3) > y end) + bench("min/1", do: min(@string)) + bench("min/2", do: min(@string, by: fn x, y -> Integer.mod(x, 3) > y end)) - bench "sum/1", do: sum(@string) - bench "product/1", do: product(@string) + bench("sum/1", do: sum(@string)) + bench("product/1", do: product(@string)) bench "random/1" do random(@string) - true # get Benchfella to match on multiple runs + # get Benchfella to match on multiple runs + true end - bench "fold/1", do: fold(@string) - bench "fold_map/2", do: fold_map(@string, fn x -> [x, x + 1] end) + bench("fold/1", do: fold(@string)) + bench("fold_map/2", do: fold_map(@string, fn x -> [x, x + 1] end)) - bench "left_fold/2", do: left_fold(@string, fn(acc, x) -> "#{x}-#{acc}" end) - bench "left_fold/3", do: left_fold(@string, @string, fn(acc, x) -> "#{x}-#{acc}" end) + bench("left_fold/2", do: left_fold(@string, fn acc, x -> "#{x}-#{acc}" end)) + bench("left_fold/3", do: left_fold(@string, @string, fn acc, x -> "#{x}-#{acc}" end)) - bench "right_fold/2", do: right_fold(@string, fn(x, acc) -> "#{x}-#{acc}" end) - bench "right_fold/3", do: right_fold(@string, @string, fn(acc, x) -> "#{x}-#{acc}" end) + bench("right_fold/2", do: right_fold(@string, fn x, acc -> "#{x}-#{acc}" end)) + bench("right_fold/3", do: right_fold(@string, @string, fn acc, x -> "#{x}-#{acc}" end)) - bench "size/1", do: size(@string) + bench("size/1", do: size(@string)) - bench "String.to_charlist/1", do: String.to_charlist(@string) - bench "to_list/1", do: to_list(@string) + bench("String.to_charlist/1", do: String.to_charlist(@string)) + bench("to_list/1", do: to_list(@string)) # ---------- # # Large Data # @@ -67,44 +68,48 @@ defmodule Witchcraft.Foldable.BitStringBench do @big_string 0..10_000 |> Enum.to_list() |> inspect() - bench "$$$ flat_map/2", do: flat_map(@big_string, fn x -> [x, x <> x] end) + bench("$$$ flat_map/2", do: flat_map(@big_string, fn x -> [x, x <> x] end)) - bench "$$$ Kernel.string_size/1", do: String.length(@big_string) + bench("$$$ Kernel.string_size/1", do: String.length(@big_string)) - bench "$$$ count/1", do: count(@big_string) - bench "$$$ length/1", do: length(@big_string) + bench("$$$ count/1", do: count(@big_string)) + bench("$$$ length/1", do: length(@big_string)) - bench "$$$ empty?/1", do: empty?(@big_string) - bench "$$$ null?/1", do: null?(@big_string) + bench("$$$ empty?/1", do: empty?(@big_string)) + bench("$$$ null?/1", do: null?(@big_string)) - bench "$$$ member?/2", do: member?(@big_string, 99) + bench("$$$ member?/2", do: member?(@big_string, 99)) - bench "$$$ max/1", do: max(@big_string) - bench "$$$ max/2", do: max(@big_string, by: fn(x, y) -> Integer.mod(x, 3) > y end) + bench("$$$ max/1", do: max(@big_string)) + bench("$$$ max/2", do: max(@big_string, by: fn x, y -> Integer.mod(x, 3) > y end)) - bench "$$$ min/1", do: min(@big_string) - bench "$$$ min/2", do: min(@big_string, by: fn(x, y) -> Integer.mod(x, 3) > y end) + bench("$$$ min/1", do: min(@big_string)) + bench("$$$ min/2", do: min(@big_string, by: fn x, y -> Integer.mod(x, 3) > y end)) - bench "$$$ sum/1", do: sum(@big_string) - bench "$$$ product/1", do: product(@big_string) + bench("$$$ sum/1", do: sum(@big_string)) + bench("$$$ product/1", do: product(@big_string)) bench "$$$ random/1" do random(@big_string) - true # get Benchfella to match on multiple runs + # get Benchfella to match on multiple runs + true end - bench "$$$ fold/1", do: fold(@big_string) - bench "$$$ fold_map/2", do: fold_map(@big_string, fn x -> [x, x + 1] end) + bench("$$$ fold/1", do: fold(@big_string)) + bench("$$$ fold_map/2", do: fold_map(@big_string, fn x -> [x, x + 1] end)) - bench "$$$ left_fold/2", do: left_fold(@big_string, fn(acc, x) -> "#{x}-#{acc}" end) - bench "$$$ left_fold/3", do: left_fold(@big_string, @big_string, fn(acc, x) -> "#{x}-#{acc}" end) + bench("$$$ left_fold/2", do: left_fold(@big_string, fn acc, x -> "#{x}-#{acc}" end)) - bench "$$$ right_fold/2", do: right_fold(@big_string, fn(x, acc) -> "#{x}-#{acc}" end) - bench "$$$ right_fold/3", do: right_fold(@big_string, @big_string, fn(acc, x) -> "#{x}-#{acc}" end) + bench("$$$ left_fold/3", do: left_fold(@big_string, @big_string, fn acc, x -> "#{x}-#{acc}" end)) - bench "$$$ size/1", do: size(@big_string) + bench("$$$ right_fold/2", do: right_fold(@big_string, fn x, acc -> "#{x}-#{acc}" end)) - bench "$$$ String.to_charlist/1", do: String.to_charlist(@big_string) - bench "$$$ to_list/1", do: to_list(@big_string) + bench("$$$ right_fold/3", + do: right_fold(@big_string, @big_string, fn acc, x -> "#{x}-#{acc}" end) + ) + bench("$$$ size/1", do: size(@big_string)) + + bench("$$$ String.to_charlist/1", do: String.to_charlist(@big_string)) + bench("$$$ to_list/1", do: to_list(@big_string)) end diff --git a/bench/witchcraft/foldable/list_bench.exs b/bench/witchcraft/foldable/list_bench.exs index 311b8fd..0452254 100644 --- a/bench/witchcraft/foldable/list_bench.exs +++ b/bench/witchcraft/foldable/list_bench.exs @@ -20,91 +20,95 @@ defmodule Witchcraft.Foldable.ListBench do # Foldable # ############ - bench "Enum.all?/1", do: Enum.all?([true, true, true, true, false]) + bench("Enum.all?/1", do: Enum.all?([true, true, true, true, false])) - bench "all?/1", do: all?([true, true, true, true, true, false]) - bench "all?/2", do: all?(@list, fn x -> x > 5 end) + bench("all?/1", do: all?([true, true, true, true, true, false])) + bench("all?/2", do: all?(@list, fn x -> x > 5 end)) - bench "Enum.any?/1", do: Enum.any?([true, true, true, true, false]) + bench("Enum.any?/1", do: Enum.any?([true, true, true, true, false])) - bench "any?/1", do: any?([true, true, true, true, true, false]) - bench "any?/2", do: any?(@list, fn x -> x > 5 end) + bench("any?/1", do: any?([true, true, true, true, true, false])) + bench("any?/2", do: any?(@list, fn x -> x > 5 end)) - bench "List.flatten/1", do: List.flatten([@list, @list, @list]) - bench "flatten/1", do: flatten([@list, @list, @list]) + bench("List.flatten/1", do: List.flatten([@list, @list, @list])) + bench("flatten/1", do: flatten([@list, @list, @list])) - bench "Enum.flat_map/2", do: Enum.flat_map(@list, fn x -> [x, x + 1] end) - bench "flat_map/2", do: flat_map(@list, fn x -> [x, x + 1] end) + bench("Enum.flat_map/2", do: Enum.flat_map(@list, fn x -> [x, x + 1] end)) + bench("flat_map/2", do: flat_map(@list, fn x -> [x, x + 1] end)) - bench "Enum.count/1", do: Enum.count(@list) + bench("Enum.count/1", do: Enum.count(@list)) - bench "count/1", do: count(@list) - bench "length/1", do: length(@list) + bench("count/1", do: count(@list)) + bench("length/1", do: length(@list)) - bench "empty?/1", do: empty?(@list) - bench "null?/1", do: null?(@list) + bench("empty?/1", do: empty?(@list)) + bench("null?/1", do: null?(@list)) - bench "Enum.member?/2", do: Enum.member?(@list, 99) - bench "member?/2", do: member?(@list, 99) + bench("Enum.member?/2", do: Enum.member?(@list, 99)) + bench("member?/2", do: member?(@list, 99)) - bench "Enum.max/1", do: Enum.max(@list) - bench "max/1", do: max(@list) + bench("Enum.max/1", do: Enum.max(@list)) + bench("max/1", do: max(@list)) - bench "Enum.max_by/2", do: Enum.max_by(@list, fn(x) -> Integer.mod(x, 3) end) # Cheating a bit - bench "max/2", do: max(@list, by: fn(x, y) -> Integer.mod(x, 3) > y end) + # Cheating a bit + bench("Enum.max_by/2", do: Enum.max_by(@list, fn x -> Integer.mod(x, 3) end)) + bench("max/2", do: max(@list, by: fn x, y -> Integer.mod(x, 3) > y end)) - bench "Enum.min/1", do: Enum.min(@list) - bench "min/1", do: min(@list) + bench("Enum.min/1", do: Enum.min(@list)) + bench("min/1", do: min(@list)) - bench "Enum.min_by/2", do: Enum.min_by(@list, fn(x) -> Integer.mod(x, 3) end) # Cheating a bit - bench "min/2", do: min(@list, by: fn(x, y) -> Integer.mod(x, 3) > y end) + # Cheating a bit + bench("Enum.min_by/2", do: Enum.min_by(@list, fn x -> Integer.mod(x, 3) end)) + bench("min/2", do: min(@list, by: fn x, y -> Integer.mod(x, 3) > y end)) - bench "Enum.sum/1", do: Enum.sum(@list) - bench "sum/1", do: sum(@list) + bench("Enum.sum/1", do: Enum.sum(@list)) + bench("sum/1", do: sum(@list)) - bench "&Enum.reduce(&1, &*/2)", do: Enum.reduce(@list, &*/2) - bench "product/1", do: product(@list) + bench("&Enum.reduce(&1, &*/2)", do: Enum.reduce(@list, &*/2)) + bench("product/1", do: product(@list)) bench "Enum.random/1" do Enum.random(@list) - true # get Benchfella to match on multiple runs + # get Benchfella to match on multiple runs + true end bench "random/1" do random(@list) - true # get Benchfella to match on multiple runs + # get Benchfella to match on multiple runs + true end - bench "fold/1", do: fold(@list) - bench "fold_map/2", do: fold_map(@list, fn x -> [x, x + 1] end) + bench("fold/1", do: fold(@list)) + bench("fold_map/2", do: fold_map(@list, fn x -> [x, x + 1] end)) bench "Enum.map_reduce/3 + []" do @list - |> Enum.map_reduce([], fn(x, acc) -> {[x + 1 | acc], nil} end) + |> Enum.map_reduce([], fn x, acc -> {[x + 1 | acc], nil} end) |> elem(0) end - bench "left_fold/2", do: left_fold(@list, fn(acc, x) -> [x + 1 | acc] end) - bench "left_fold/3", do: left_fold(@list, @list, fn(acc, x) -> [x + 1 | acc] end) + bench("left_fold/2", do: left_fold(@list, fn acc, x -> [x + 1 | acc] end)) + bench("left_fold/3", do: left_fold(@list, @list, fn acc, x -> [x + 1 | acc] end)) - bench "List.foldl/3 + []", do: List.foldl(@list, [], fn(x, acc) -> [x + 1 | acc]end) - bench "List.foldl/3", do: List.foldl(@list, @list, fn(x, acc) -> [x + 1 | acc] end) + bench("List.foldl/3 + []", do: List.foldl(@list, [], fn x, acc -> [x + 1 | acc] end)) + bench("List.foldl/3", do: List.foldl(@list, @list, fn x, acc -> [x + 1 | acc] end)) - bench "right_fold/3 + []", do: right_fold(@list, [], fn(x, acc) -> [x + 1 | acc] end) - bench "right_fold/3", do: right_fold(@list, @list, fn(x, acc) -> [x + 1 | acc] end) + bench("right_fold/3 + []", do: right_fold(@list, [], fn x, acc -> [x + 1 | acc] end)) + bench("right_fold/3", do: right_fold(@list, @list, fn x, acc -> [x + 1 | acc] end)) - bench "Enum.reduce/2", do: Enum.reduce(@list, fn(x, acc) -> [x + 1 | acc] end) - bench "Enum.reduce/3", do: Enum.reduce(@list, @list, fn(x, acc) -> [x + 1 | acc] end) + bench("Enum.reduce/2", do: Enum.reduce(@list, fn x, acc -> [x + 1 | acc] end)) + bench("Enum.reduce/3", do: Enum.reduce(@list, @list, fn x, acc -> [x + 1 | acc] end)) - bench "List.foldr/3 + []", do: List.foldr(@list, [], fn(x, acc) -> [x + 1 | acc]end) - bench "List.foldr/3", do: List.foldr(@list, @list, fn(x, acc) -> [x + 1 | acc] end) + bench("List.foldr/3 + []", do: List.foldr(@list, [], fn x, acc -> [x + 1 | acc] end)) + bench("List.foldr/3", do: List.foldr(@list, @list, fn x, acc -> [x + 1 | acc] end)) - bench "size/1", do: size(@list) + bench("size/1", do: size(@list)) - bench "then_sequence/1", do: then_sequence([@list, @list, @list]) + bench("then_sequence/1", do: then_sequence([@list, @list, @list])) - bench "Enum.to_list/1", do: Enum.to_list(@list) - bench "to_list/1", do: to_list(@list) + bench("Enum.to_list/1", do: Enum.to_list(@list)) + bench("to_list/1", do: to_list(@list)) bench "then_traverse/2" do @list @@ -122,97 +126,105 @@ defmodule Witchcraft.Foldable.ListBench do @big_list Enum.to_list(0..10_000) @med_list Enum.to_list(0..250) - @bools Enum.map(@big_list, fn _ -> Enum.random([true, false]) end) + @bools Enum.map(@big_list, fn _ -> Enum.random([true, false]) end) @nested fn -> [1, 2, 3] end |> Stream.repeatedly() |> Enum.take(10) - bench "$$$ Enum.all?/1", do: Enum.all?(@bools) + bench("$$$ Enum.all?/1", do: Enum.all?(@bools)) - bench "$$$ all?/1", do: all?(@bools) - bench "$$$ all?/2", do: all?(@big_list, fn x -> x > 5 end) + bench("$$$ all?/1", do: all?(@bools)) + bench("$$$ all?/2", do: all?(@big_list, fn x -> x > 5 end)) - bench "$$$ Enum.any?/1", do: Enum.any?(@bools) + bench("$$$ Enum.any?/1", do: Enum.any?(@bools)) - bench "$$$ any?/1", do: any?([true, true, true, true, true, false]) - bench "$$$ any?/2", do: any?(@big_list, fn x -> x > 5 end) + bench("$$$ any?/1", do: any?([true, true, true, true, true, false])) + bench("$$$ any?/2", do: any?(@big_list, fn x -> x > 5 end)) - bench "$$$ List.flatten/1", do: List.flatten([@big_list, @big_list, @big_list, @big_list, @big_list]) - bench "$$$ flatten/1", do: flatten([@big_list, @big_list, @big_list, @big_list, @big_list]) + bench("$$$ List.flatten/1", + do: List.flatten([@big_list, @big_list, @big_list, @big_list, @big_list]) + ) - bench "$$$ Enum.flat_map/2", do: Enum.flat_map(@big_list, fn x -> [x, x + 1] end) - bench "$$$ flat_map/2", do: flat_map(@big_list, fn x -> [x, x + 1] end) + bench("$$$ flatten/1", do: flatten([@big_list, @big_list, @big_list, @big_list, @big_list])) - bench "$$$ Enum.count/1", do: Enum.count(@big_list) + bench("$$$ Enum.flat_map/2", do: Enum.flat_map(@big_list, fn x -> [x, x + 1] end)) + bench("$$$ flat_map/2", do: flat_map(@big_list, fn x -> [x, x + 1] end)) - bench "$$$ Enum.count/1", do: Enum.count(@big_list) + bench("$$$ Enum.count/1", do: Enum.count(@big_list)) - bench "$$$ count/1", do: count(@big_list) - bench "$$$ length/1", do: length(@big_list) + bench("$$$ Enum.count/1", do: Enum.count(@big_list)) - bench "$$$ empty?/1", do: empty?(@big_list) - bench "$$$ null?/1", do: null?(@big_list) + bench("$$$ count/1", do: count(@big_list)) + bench("$$$ length/1", do: length(@big_list)) - bench "$$$ Enum.member?/2", do: Enum.member?(@big_list, 99) - bench "$$$ member?/2", do: member?(@big_list, 99) + bench("$$$ empty?/1", do: empty?(@big_list)) + bench("$$$ null?/1", do: null?(@big_list)) - bench "$$$ Enum.max/1", do: Enum.max(@big_list) - bench "$$$ max/1", do: max(@big_list) + bench("$$$ Enum.member?/2", do: Enum.member?(@big_list, 99)) + bench("$$$ member?/2", do: member?(@big_list, 99)) - bench "$$$ Enum.max_by/2", do: Enum.max_by(@big_list, fn(x) -> Integer.mod(x, 3) end) # Cheating a bit - bench "$$$ max/2", do: max(@big_list, by: fn(x, y) -> Integer.mod(x, 3) > y end) + bench("$$$ Enum.max/1", do: Enum.max(@big_list)) + bench("$$$ max/1", do: max(@big_list)) - bench "$$$ Enum.min/1", do: Enum.min(@big_list) - bench "$$$ min/1", do: min(@big_list) + # Cheating a bit + bench("$$$ Enum.max_by/2", do: Enum.max_by(@big_list, fn x -> Integer.mod(x, 3) end)) + bench("$$$ max/2", do: max(@big_list, by: fn x, y -> Integer.mod(x, 3) > y end)) - bench "$$$ Enum.min_by/2", do: Enum.min_by(@big_list, fn(x) -> Integer.mod(x, 3) end) # Cheating a bit - bench "$$$ min/2", do: min(@big_list, by: fn(x, y) -> Integer.mod(x, 3) > y end) + bench("$$$ Enum.min/1", do: Enum.min(@big_list)) + bench("$$$ min/1", do: min(@big_list)) - bench "$$$ Enum.sum/1", do: Enum.sum(@big_list) - bench "$$$ sum/1", do: sum(@big_list) + # Cheating a bit + bench("$$$ Enum.min_by/2", do: Enum.min_by(@big_list, fn x -> Integer.mod(x, 3) end)) + bench("$$$ min/2", do: min(@big_list, by: fn x, y -> Integer.mod(x, 3) > y end)) - bench "$$$ &Enum.reduce(&1, &*/2)", do: Enum.reduce(@big_list, &*/2) - bench "$$$ product/1", do: product(@big_list) + bench("$$$ Enum.sum/1", do: Enum.sum(@big_list)) + bench("$$$ sum/1", do: sum(@big_list)) + + bench("$$$ &Enum.reduce(&1, &*/2)", do: Enum.reduce(@big_list, &*/2)) + bench("$$$ product/1", do: product(@big_list)) bench "$$$ Enum.random/1" do Enum.random(@big_list) - true # get Benchfella to match on multiple runs + # get Benchfella to match on multiple runs + true end bench "$$$ random/1" do random(@big_list) - true # get Benchfella to match on multiple runs + # get Benchfella to match on multiple runs + true end - bench "$$$ fold/1", do: fold(@big_list) - bench "$$$ fold_map/2", do: fold_map(@big_list, fn x -> [x, x + 1] end) + bench("$$$ fold/1", do: fold(@big_list)) + bench("$$$ fold_map/2", do: fold_map(@big_list, fn x -> [x, x + 1] end)) bench "$$$ Enum.map_reduce/3 + []" do @big_list - |> Enum.map_reduce([], fn(x, acc) -> {[x + 1 | acc], nil} end) + |> Enum.map_reduce([], fn x, acc -> {[x + 1 | acc], nil} end) |> elem(0) end - bench "$$$ left_fold/2", do: left_fold(@big_list, fn(acc, x) -> [x + 1 | acc] end) - bench "$$$ left_fold/3", do: left_fold(@big_list, @big_list, fn(acc, x) -> [x + 1 | acc] end) + bench("$$$ left_fold/2", do: left_fold(@big_list, fn acc, x -> [x + 1 | acc] end)) + bench("$$$ left_fold/3", do: left_fold(@big_list, @big_list, fn acc, x -> [x + 1 | acc] end)) + + bench("$$$ List.foldl/3 + []", do: List.foldl(@big_list, [], fn x, acc -> [x + 1 | acc] end)) + bench("$$$ List.foldl/3", do: List.foldl(@big_list, @big_list, fn x, acc -> [x + 1 | acc] end)) - bench "$$$ List.foldl/3 + []", do: List.foldl(@big_list, [], fn(x, acc) -> [x + 1 | acc]end) - bench "$$$ List.foldl/3", do: List.foldl(@big_list, @big_list, fn(x, acc) -> [x + 1 | acc] end) + bench("$$$ right_fold/3 + []", do: right_fold(@big_list, [], fn x, acc -> [x + 1 | acc] end)) + bench("$$$ right_fold/3", do: right_fold(@big_list, @big_list, fn x, acc -> [x + 1 | acc] end)) - bench "$$$ right_fold/3 + []", do: right_fold(@big_list, [], fn(x, acc) -> [x + 1 | acc] end) - bench "$$$ right_fold/3", do: right_fold(@big_list, @big_list, fn(x, acc) -> [x + 1 | acc] end) + bench("$$$ Enum.reduce/2", do: Enum.reduce(@big_list, fn x, acc -> [x + 1 | acc] end)) - bench "$$$ Enum.reduce/2", do: Enum.reduce(@big_list, fn(x, acc) -> [x + 1 | acc] end) - bench "$$$ Enum.reduce/3", do: Enum.reduce(@big_list, @big_list, fn(x, acc) -> [x + 1 | acc] end) + bench("$$$ Enum.reduce/3", do: Enum.reduce(@big_list, @big_list, fn x, acc -> [x + 1 | acc] end)) - bench "$$$ List.foldr/3 + []", do: List.foldr(@big_list, [], fn(x, acc) -> [x + 1 | acc]end) - bench "$$$ List.foldr/3", do: List.foldr(@big_list, @big_list, fn(x, acc) -> [x + 1 | acc] end) + bench("$$$ List.foldr/3 + []", do: List.foldr(@big_list, [], fn x, acc -> [x + 1 | acc] end)) + bench("$$$ List.foldr/3", do: List.foldr(@big_list, @big_list, fn x, acc -> [x + 1 | acc] end)) - bench "$$$ size/1", do: size(@big_list) + bench("$$$ size/1", do: size(@big_list)) - bench "$$$ med then_sequence/1", do: then_sequence([@med_list, @med_list, @med_list]) - bench "$$$ sml then_sequence/1", do: then_sequence(@nested) + bench("$$$ med then_sequence/1", do: then_sequence([@med_list, @med_list, @med_list])) + bench("$$$ sml then_sequence/1", do: then_sequence(@nested)) - bench "$$$ Enum.to_list/1", do: Enum.to_list(@big_list) - bench "$$$ to_list/1", do: to_list(@big_list) + bench("$$$ Enum.to_list/1", do: Enum.to_list(@big_list)) + bench("$$$ to_list/1", do: to_list(@big_list)) bench "$$$ then_traverse/2" do @big_list @@ -223,5 +235,4 @@ defmodule Witchcraft.Foldable.ListBench do bench "$$$ then_through/2" do fn y -> [y, y] end |> then_through(fn x -> [x + 1] end |> then_through(@big_list)) end - end diff --git a/bench/witchcraft/foldable/map_bench.exs b/bench/witchcraft/foldable/map_bench.exs index e2d650a..9fed755 100644 --- a/bench/witchcraft/foldable/map_bench.exs +++ b/bench/witchcraft/foldable/map_bench.exs @@ -27,8 +27,8 @@ defmodule Witchcraft.Foldable.MapBench do |> Enum.all?() end - bench "all?/1", do: all?(%{a: true, b: false, c: true, d: true, e: false}) - bench "all?/2", do: all?(@map, fn x -> x > 5 end) + bench("all?/1", do: all?(%{a: true, b: false, c: true, d: true, e: false})) + bench("all?/2", do: all?(@map, fn x -> x > 5 end)) bench "Enum.any?/1" do %{a: true, b: false, c: true, d: true, e: false} @@ -36,87 +36,104 @@ defmodule Witchcraft.Foldable.MapBench do |> Enum.any?() end - bench "any?/1", do: any?(%{a: true, b: false, c: true, d: true, e: false}) - bench "any?/2", do: any?(@map, fn x -> x > 5 end) + bench("any?/1", do: any?(%{a: true, b: false, c: true, d: true, e: false})) + bench("any?/2", do: any?(@map, fn x -> x > 5 end)) - bench "flatten/1", do: flatten(%{a: @list, b: @list, c: @list, d: @list}) + bench("flatten/1", do: flatten(%{a: @list, b: @list, c: @list, d: @list})) - bench "Enum.flat_map/2", do: @map |> Map.values() |> Enum.flat_map(fn x -> [x, x + 1] end) - bench "flat_map/2", do: flat_map(@map, fn x -> [x, x + 1] end) + bench("Enum.flat_map/2", do: @map |> Map.values() |> Enum.flat_map(fn x -> [x, x + 1] end)) + bench("flat_map/2", do: flat_map(@map, fn x -> [x, x + 1] end)) - bench "Enum.count/1", do: Enum.count(@map) + bench("Enum.count/1", do: Enum.count(@map)) - bench "count/1", do: count(@map) - bench "length/1", do: length(@map) + bench("count/1", do: count(@map)) + bench("length/1", do: length(@map)) - bench "empty?/1", do: empty?(@map) - bench "null?/1", do: null?(@map) + bench("empty?/1", do: empty?(@map)) + bench("null?/1", do: null?(@map)) - bench "Enum.member?/2", do: @map |> Map.values() |> Enum.member?(99) - bench "member?/2", do: member?(@map, 99) + bench("Enum.member?/2", do: @map |> Map.values() |> Enum.member?(99)) + bench("member?/2", do: member?(@map, 99)) - bench "Enum.max/1", do: @map |> Map.values() |> Enum.max() - bench "max/1", do: max(@map) + bench("Enum.max/1", do: @map |> Map.values() |> Enum.max()) + bench("max/1", do: max(@map)) - bench "Enum.max_by/2", do: @map |> Map.values() |> Enum.max_by(fn(x) -> Integer.mod(x, 3) end) # Cheating a bit - bench "max/2", do: max(@map, by: fn(x, y) -> Integer.mod(x, 3) > y end) + # Cheating a bit + bench("Enum.max_by/2", do: @map |> Map.values() |> Enum.max_by(fn x -> Integer.mod(x, 3) end)) + bench("max/2", do: max(@map, by: fn x, y -> Integer.mod(x, 3) > y end)) - bench "Enum.min/1", do: @map |> Map.values() |> Enum.min() - bench "min/1", do: min(@map) + bench("Enum.min/1", do: @map |> Map.values() |> Enum.min()) + bench("min/1", do: min(@map)) - bench "Enum.min_by/2", do: @map |> Map.values() |> Enum.min_by(fn(x) -> Integer.mod(x, 3) end) # Cheating a bit - bench "min/2", do: min(@map, by: fn(x, y) -> Integer.mod(x, 3) > y end) + # Cheating a bit + bench("Enum.min_by/2", do: @map |> Map.values() |> Enum.min_by(fn x -> Integer.mod(x, 3) end)) + bench("min/2", do: min(@map, by: fn x, y -> Integer.mod(x, 3) > y end)) - bench "Enum.sum/1", do: @map |> Map.values() |> Enum.sum() - bench "sum/1", do: sum(@map) + bench("Enum.sum/1", do: @map |> Map.values() |> Enum.sum()) + bench("sum/1", do: sum(@map)) - bench "&Enum.reduce(&1, &*/2)", do: @map |> Map.values() |> Enum.reduce(&*/2) - bench "product/1", do: product(@map) + bench("&Enum.reduce(&1, &*/2)", do: @map |> Map.values() |> Enum.reduce(&*/2)) + bench("product/1", do: product(@map)) bench "Enum.random/1" do @map |> Map.values() |> Enum.random() - true # get Benchfella to match on multiple runs + # get Benchfella to match on multiple runs + true end bench "random/1" do random(@map) - true # get Benchfella to match on multiple runs + # get Benchfella to match on multiple runs + true end - bench "fold/1", do: fold(@map) - bench "fold_map/2", do: fold_map(@map, fn x -> [x, x + 1] end) + bench("fold/1", do: fold(@map)) + bench("fold_map/2", do: fold_map(@map, fn x -> [x, x + 1] end)) bench "Enum.map_reduce/3 + []" do @map |> Map.values() - |> Enum.map_reduce([], fn(x, acc) -> {[x + 1 | acc], nil} end) + |> Enum.map_reduce([], fn x, acc -> {[x + 1 | acc], nil} end) |> elem(0) end - bench "left_fold/2", do: left_fold(@map, fn(acc, x) -> [x + 1 | acc] end) - bench "left_fold/3", do: left_fold(@map, @map, fn(acc, x) -> [x + 1 | acc] end) + bench("left_fold/2", do: left_fold(@map, fn acc, x -> [x + 1 | acc] end)) + bench("left_fold/3", do: left_fold(@map, @map, fn acc, x -> [x + 1 | acc] end)) - bench "List.foldl/3 + []", do: @map |> Map.values() |> List.foldl([], fn(x, acc) -> [x + 1 | acc]end) - bench "List.foldl/3", do: List.foldl(Map.values(@map), Map.values(@map), fn(x, acc) -> [x + 1 | acc] end) + bench("List.foldl/3 + []", + do: @map |> Map.values() |> List.foldl([], fn x, acc -> [x + 1 | acc] end) + ) - bench "right_fold/3 + []", do: right_fold(@map, [], fn(x, acc) -> [x + 1 | acc] end) - bench "right_fold/3", do: right_fold(@map, @map, fn(x, acc) -> [x + 1 | acc] end) + bench("List.foldl/3", + do: List.foldl(Map.values(@map), Map.values(@map), fn x, acc -> [x + 1 | acc] end) + ) - bench "Enum.reduce/2", do: @map |> Map.values() |> Enum.reduce(fn(x, acc) -> [x + 1 | acc] end) - bench "Enum.reduce/3", do: Enum.reduce(Map.values(@map), Map.values(@map), fn(x, acc) -> [x + 1 | acc] end) + bench("right_fold/3 + []", do: right_fold(@map, [], fn x, acc -> [x + 1 | acc] end)) + bench("right_fold/3", do: right_fold(@map, @map, fn x, acc -> [x + 1 | acc] end)) - bench "List.foldr/3 + []", do: @map |> Map.values() |> List.foldr([], fn(x, acc) -> [x + 1 | acc]end) - bench "List.foldr/3", do: List.foldr(Map.values(@map), Map.values(@map), fn(x, acc) -> [x + 1 | acc] end) + bench("Enum.reduce/2", do: @map |> Map.values() |> Enum.reduce(fn x, acc -> [x + 1 | acc] end)) - bench "size/1", do: size(@map) + bench("Enum.reduce/3", + do: Enum.reduce(Map.values(@map), Map.values(@map), fn x, acc -> [x + 1 | acc] end) + ) - bench "then_sequence/1", do: then_sequence(%{a: @list, b: @list, c: @list, d: @list}) + bench("List.foldr/3 + []", + do: @map |> Map.values() |> List.foldr([], fn x, acc -> [x + 1 | acc] end) + ) - bench "Map.values/1", do: Map.values(@map) - bench "to_list/1", do: to_list(@map) + bench("List.foldr/3", + do: List.foldr(Map.values(@map), Map.values(@map), fn x, acc -> [x + 1 | acc] end) + ) + + bench("size/1", do: size(@map)) + + bench("then_sequence/1", do: then_sequence(%{a: @list, b: @list, c: @list, d: @list})) + + bench("Map.values/1", do: Map.values(@map)) + bench("to_list/1", do: to_list(@map)) # ---------- # # Large Data # @@ -127,7 +144,7 @@ defmodule Witchcraft.Foldable.MapBench do @big_map @big_list |> Enum.zip(@big_list) |> Enum.into(%{}) - @bools Enum.map(@big_map, fn _ -> Enum.random([true, false]) end) + @bools Enum.map(@big_map, fn _ -> Enum.random([true, false]) end) @nested fn -> [1, 2, 3] end |> Stream.repeatedly() |> Enum.take(10) bench "$$$ Enum.all?/1" do @@ -136,8 +153,8 @@ defmodule Witchcraft.Foldable.MapBench do |> Enum.all?() end - bench "$$$ all?/1", do: all?(%{a: true, b: false, c: true, d: true, e: false}) - bench "$$$ all?/2", do: all?(@big_map, fn x -> x > 5 end) + bench("$$$ all?/1", do: all?(%{a: true, b: false, c: true, d: true, e: false})) + bench("$$$ all?/2", do: all?(@big_map, fn x -> x > 5 end)) bench "$$$ Enum.any?/1" do %{a: true, b: false, c: true, d: true, e: false} @@ -145,98 +162,115 @@ defmodule Witchcraft.Foldable.MapBench do |> Enum.any?() end - bench "$$$ any?/1", do: any?(%{a: true, b: false, c: true, d: true, e: false}) - bench "$$$ any?/2", do: any?(@big_map, fn x -> x > 5 end) + bench("$$$ any?/1", do: any?(%{a: true, b: false, c: true, d: true, e: false})) + bench("$$$ any?/2", do: any?(@big_map, fn x -> x > 5 end)) + + bench("$$$ flatten/1", do: flatten(%{a: @big_list, b: @big_list, c: @big_list, d: @big_list})) - bench "$$$ flatten/1", do: flatten(%{a: @big_list, b: @big_list, c: @big_list, d: @big_list}) + bench("$$$ Enum.flat_map/2", + do: @big_map |> Map.values() |> Enum.flat_map(fn x -> [x, x + 1] end) + ) - bench "$$$ Enum.flat_map/2", do: @big_map |> Map.values() |> Enum.flat_map(fn x -> [x, x + 1] end) - bench "$$$ flat_map/2", do: flat_map(@big_map, fn x -> [x, x + 1] end) + bench("$$$ flat_map/2", do: flat_map(@big_map, fn x -> [x, x + 1] end)) - bench "$$$ Enum.count/1", do: Enum.count(@big_map) + bench("$$$ Enum.count/1", do: Enum.count(@big_map)) - bench "$$$ count/1", do: count(@big_map) - bench "$$$ length/1", do: length(@big_map) + bench("$$$ count/1", do: count(@big_map)) + bench("$$$ length/1", do: length(@big_map)) - bench "$$$ empty?/1", do: empty?(@big_map) - bench "$$$ null?/1", do: null?(@big_map) + bench("$$$ empty?/1", do: empty?(@big_map)) + bench("$$$ null?/1", do: null?(@big_map)) - bench "$$$ Enum.member?/2", do: @big_map |> Map.values() |> Enum.member?(99) - bench "$$$ member?/2", do: member?(@big_map, 99) + bench("$$$ Enum.member?/2", do: @big_map |> Map.values() |> Enum.member?(99)) + bench("$$$ member?/2", do: member?(@big_map, 99)) - bench "$$$ Enum.max/1", do: @big_map |> Map.values() |> Enum.max() - bench "$$$ max/1", do: max(@big_map) + bench("$$$ Enum.max/1", do: @big_map |> Map.values() |> Enum.max()) + bench("$$$ max/1", do: max(@big_map)) - bench "$$$ Enum.max_by/2", do: @big_map |> Map.values() |> Enum.max_by(fn(x) -> Integer.mod(x, 3) end) # Cheating a bit - bench "$$$ max/2", do: max(@big_map, by: fn(x, y) -> Integer.mod(x, 3) > y end) + # Cheating a bit + bench("$$$ Enum.max_by/2", + do: @big_map |> Map.values() |> Enum.max_by(fn x -> Integer.mod(x, 3) end) + ) - bench "$$$ Enum.min/1", do: @big_map |> Map.values() |> Enum.min() - bench "$$$ min/1", do: min(@big_map) + bench("$$$ max/2", do: max(@big_map, by: fn x, y -> Integer.mod(x, 3) > y end)) - bench "$$$ Enum.min_by/2", do: @big_map |> Map.values() |> Enum.min_by(fn(x) -> Integer.mod(x, 3) end) # Cheating a bit - bench "$$$ min/2", do: min(@big_map, by: fn(x, y) -> Integer.mod(x, 3) > y end) + bench("$$$ Enum.min/1", do: @big_map |> Map.values() |> Enum.min()) + bench("$$$ min/1", do: min(@big_map)) - bench "$$$ Enum.sum/1", do: @big_map |> Map.values() |> Enum.sum() - bench "$$$ sum/1", do: sum(@big_map) + # Cheating a bit + bench("$$$ Enum.min_by/2", + do: @big_map |> Map.values() |> Enum.min_by(fn x -> Integer.mod(x, 3) end) + ) - bench "$$$ &Enum.reduce(&1, &*/2)", do: @big_map |> Map.values() |> Enum.reduce(&*/2) - bench "$$$ product/1", do: product(@big_map) + bench("$$$ min/2", do: min(@big_map, by: fn x, y -> Integer.mod(x, 3) > y end)) + + bench("$$$ Enum.sum/1", do: @big_map |> Map.values() |> Enum.sum()) + bench("$$$ sum/1", do: sum(@big_map)) + + bench("$$$ &Enum.reduce(&1, &*/2)", do: @big_map |> Map.values() |> Enum.reduce(&*/2)) + bench("$$$ product/1", do: product(@big_map)) bench "$$$ Enum.random/1" do @big_map |> Map.values() |> Enum.random() - true # get Benchfella to match on multiple runs + # get Benchfella to match on multiple runs + true end bench "$$$ random/1" do random(@big_map) - true # get Benchfella to match on multiple runs + # get Benchfella to match on multiple runs + true end - bench "$$$ fold/1", do: fold(@big_map) - bench "$$$ fold_map/2", do: fold_map(@big_map, fn x -> [x, x + 1] end) + bench("$$$ fold/1", do: fold(@big_map)) + bench("$$$ fold_map/2", do: fold_map(@big_map, fn x -> [x, x + 1] end)) bench "$$$ Enum.map_reduce/3 + []" do @big_map |> Map.values() - |> Enum.map_reduce([], fn(x, acc) -> {[x + 1 | acc], nil} end) + |> Enum.map_reduce([], fn x, acc -> {[x + 1 | acc], nil} end) |> elem(0) end - bench "$$$ left_fold/2", do: left_fold(@big_map, fn(acc, x) -> [x + 1 | acc] end) - bench "$$$ left_fold/3", do: left_fold(@big_map, @big_map, fn(acc, x) -> [x + 1 | acc] end) + bench("$$$ left_fold/2", do: left_fold(@big_map, fn acc, x -> [x + 1 | acc] end)) + bench("$$$ left_fold/3", do: left_fold(@big_map, @big_map, fn acc, x -> [x + 1 | acc] end)) bench "$$$ List.foldl/3 + []" do @big_map |> Map.values() - |> List.foldl([], fn(x, acc) -> [x + 1 | acc]end) + |> List.foldl([], fn x, acc -> [x + 1 | acc] end) end bench "$$$ List.foldl/3" do - List.foldl(Map.values(@big_map), Map.values(@big_map), fn(x, acc) -> [x + 1 | acc] end) + List.foldl(Map.values(@big_map), Map.values(@big_map), fn x, acc -> [x + 1 | acc] end) end - bench "$$$ right_fold/3 + []", do: right_fold(@big_map, [], fn(x, acc) -> [x + 1 | acc] end) - bench "$$$ right_fold/3", do: right_fold(@big_map, @big_map, fn(x, acc) -> [x + 1 | acc] end) + bench("$$$ right_fold/3 + []", do: right_fold(@big_map, [], fn x, acc -> [x + 1 | acc] end)) + bench("$$$ right_fold/3", do: right_fold(@big_map, @big_map, fn x, acc -> [x + 1 | acc] end)) + + bench("$$$ Enum.reduce/2", + do: @big_map |> Map.values() |> Enum.reduce(fn x, acc -> [x + 1 | acc] end) + ) - bench "$$$ Enum.reduce/2", do: @big_map |> Map.values() |> Enum.reduce(fn(x, acc) -> [x + 1 | acc] end) bench "$$$ Enum.reduce/3" do - Enum.reduce(Map.values(@big_map), Map.values(@big_map), fn(x, acc) -> [x + 1 | acc] end) + Enum.reduce(Map.values(@big_map), Map.values(@big_map), fn x, acc -> [x + 1 | acc] end) end - bench "$$$ List.foldr/3 + []", do: @big_map |> Map.values() |> List.foldr([], fn(x, acc) -> [x + 1 | acc]end) + bench("$$$ List.foldr/3 + []", + do: @big_map |> Map.values() |> List.foldr([], fn x, acc -> [x + 1 | acc] end) + ) bench "$$$ List.foldr/3" do - List.foldr(Map.values(@big_map), Map.values(@big_map), fn(x, acc) -> [x + 1 | acc] end) + List.foldr(Map.values(@big_map), Map.values(@big_map), fn x, acc -> [x + 1 | acc] end) end - bench "$$$ size/1", do: size(@big_map) - - bench "$$$ then_sequence/1", do: then_sequence(%{a: @med_list, b: @med_list, c: @med_list}) + bench("$$$ size/1", do: size(@big_map)) - bench "$$$ Map.values/1", do: Map.values(@big_map) - bench "$$$ to_list/1", do: to_list(@big_map) + bench("$$$ then_sequence/1", do: then_sequence(%{a: @med_list, b: @med_list, c: @med_list})) + bench("$$$ Map.values/1", do: Map.values(@big_map)) + bench("$$$ to_list/1", do: to_list(@big_map)) end diff --git a/bench/witchcraft/foldable/tuple_bench.exs b/bench/witchcraft/foldable/tuple_bench.exs index dc60f43..0d38f83 100644 --- a/bench/witchcraft/foldable/tuple_bench.exs +++ b/bench/witchcraft/foldable/tuple_bench.exs @@ -21,57 +21,58 @@ defmodule Witchcraft.Foldable.TupleBench do # Foldable # ############ - bench "Enum.all?/1", do: {true, true, true, true, false} |> Tuple.to_list() |> Enum.all?() + bench("Enum.all?/1", do: {true, true, true, true, false} |> Tuple.to_list() |> Enum.all?()) - bench "all?/1", do: all?({true, true, true, true, true, false}) - bench "all?/2", do: all?(@tuple, fn x -> x > 5 end) + bench("all?/1", do: all?({true, true, true, true, true, false})) + bench("all?/2", do: all?(@tuple, fn x -> x > 5 end)) - bench "any?/1", do: any?({true, true, true, true, true, false}) - bench "any?/2", do: any?(@tuple, fn x -> x > 5 end) + bench("any?/1", do: any?({true, true, true, true, true, false})) + bench("any?/2", do: any?(@tuple, fn x -> x > 5 end)) - bench "flatten/1", do: flatten({[1, 2, 3], [4, 5, 6], [7, 8, 9]}) + bench("flatten/1", do: flatten({[1, 2, 3], [4, 5, 6], [7, 8, 9]})) - bench "flat_map/2", do: flat_map(@tuple, fn x -> [x, x + 1] end) + bench("flat_map/2", do: flat_map(@tuple, fn x -> [x, x + 1] end)) - bench "Kernel.tuple_size/1", do: tuple_size(@tuple) + bench("Kernel.tuple_size/1", do: tuple_size(@tuple)) - bench "count/1", do: count(@tuple) - bench "length/1", do: length(@tuple) + bench("count/1", do: count(@tuple)) + bench("length/1", do: length(@tuple)) - bench "empty?/1", do: empty?(@tuple) - bench "null?/1", do: null?(@tuple) + bench("empty?/1", do: empty?(@tuple)) + bench("null?/1", do: null?(@tuple)) - bench "member?/2", do: member?(@tuple, 99) + bench("member?/2", do: member?(@tuple, 99)) - bench "max/1", do: max(@tuple) - bench "max/2", do: max(@tuple, by: fn(x, y) -> Integer.mod(x, 3) > y end) + bench("max/1", do: max(@tuple)) + bench("max/2", do: max(@tuple, by: fn x, y -> Integer.mod(x, 3) > y end)) - bench "min/1", do: min(@tuple) - bench "min/2", do: min(@tuple, by: fn(x, y) -> Integer.mod(x, 3) > y end) + bench("min/1", do: min(@tuple)) + bench("min/2", do: min(@tuple, by: fn x, y -> Integer.mod(x, 3) > y end)) - bench "sum/1", do: sum(@tuple) - bench "product/1", do: product(@tuple) + bench("sum/1", do: sum(@tuple)) + bench("product/1", do: product(@tuple)) bench "random/1" do random(@tuple) - true # get Benchfella to match on multiple runs + # get Benchfella to match on multiple runs + true end - bench "fold/1", do: fold(@tuple) - bench "fold_map/2", do: fold_map(@tuple, fn x -> {x, x + 1} end) + bench("fold/1", do: fold(@tuple)) + bench("fold_map/2", do: fold_map(@tuple, fn x -> {x, x + 1} end)) - bench "left_fold/2", do: left_fold(@tuple, fn(acc, x) -> {x + 1 , acc} end) - bench "left_fold/3", do: left_fold(@tuple, @tuple, fn(acc, x) -> {x + 1 , acc} end) + bench("left_fold/2", do: left_fold(@tuple, fn acc, x -> {x + 1, acc} end)) + bench("left_fold/3", do: left_fold(@tuple, @tuple, fn acc, x -> {x + 1, acc} end)) - bench "right_fold/3 + {}", do: right_fold(@tuple, {1, 2}, fn(x, acc) -> {x + 1, acc} end) - bench "right_fold/3", do: right_fold(@tuple, @tuple, fn(x, acc) -> {x + 1, acc} end) + bench("right_fold/3 + {}", do: right_fold(@tuple, {1, 2}, fn x, acc -> {x + 1, acc} end)) + bench("right_fold/3", do: right_fold(@tuple, @tuple, fn x, acc -> {x + 1, acc} end)) - bench "size/1", do: size(@tuple) + bench("size/1", do: size(@tuple)) - bench "then_sequence/1", do: then_sequence({{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}) + bench("then_sequence/1", do: then_sequence({{1, 2, 3}, {4, 5, 6}, {7, 8, 9}})) - bench "Tuple.to_list/1", do: Tuple.to_list(@tuple) - bench "to_list/1", do: to_list(@tuple) + bench("Tuple.to_list/1", do: Tuple.to_list(@tuple)) + bench("to_list/1", do: to_list(@tuple)) bench "then_traverse/2" do @tuple @@ -81,8 +82,10 @@ defmodule Witchcraft.Foldable.TupleBench do bench "then_through/2" do fn y -> Tuple.duplicate(y, 11) end - |> then_through(fn x -> Tuple.duplicate(x, 11) end - |> then_through(@tuple)) + |> then_through( + fn x -> Tuple.duplicate(x, 11) end + |> then_through(@tuple) + ) end # ---------- # @@ -92,59 +95,64 @@ defmodule Witchcraft.Foldable.TupleBench do @big_tuple 0..10_000 |> Enum.to_list() |> List.to_tuple() @med_tuple 0..250 |> Enum.to_list() |> List.to_tuple() - @bools 0..250 |> Enum.to_list() |> map(fn _ -> Enum.random([true, false]) end) |> List.to_tuple() + @bools 0..250 + |> Enum.to_list() + |> map(fn _ -> Enum.random([true, false]) end) + |> List.to_tuple() @nested fn -> [1, 2, 3] end |> Stream.repeatedly() |> Enum.take(10) |> List.to_tuple() - bench "$$$ Enum.all?/1", do: @bools |> Tuple.to_list() |> Enum.all?() + bench("$$$ Enum.all?/1", do: @bools |> Tuple.to_list() |> Enum.all?()) - bench "$$$ all?/1", do: all?(@bools) - bench "$$$ all?/2", do: all?(@big_tuple, fn x -> x > 5 end) + bench("$$$ all?/1", do: all?(@bools)) + bench("$$$ all?/2", do: all?(@big_tuple, fn x -> x > 5 end)) - bench "$$$ any?/1", do: any?(@bools) - bench "$$$ any?/2", do: any?(@big_tuple, fn x -> x > 5 end) + bench("$$$ any?/1", do: any?(@bools)) + bench("$$$ any?/2", do: any?(@big_tuple, fn x -> x > 5 end)) - bench "$$$ flatten/1", do: flatten(@nested) + bench("$$$ flatten/1", do: flatten(@nested)) - bench "$$$ flat_map/2", do: flat_map(@big_tuple, fn x -> [x, x + 1] end) + bench("$$$ flat_map/2", do: flat_map(@big_tuple, fn x -> [x, x + 1] end)) - bench "$$$ Kernel.tuple_size/1", do: tuple_size(@big_tuple) + bench("$$$ Kernel.tuple_size/1", do: tuple_size(@big_tuple)) - bench "$$$ count/1", do: count(@big_tuple) - bench "$$$ length/1", do: length(@big_tuple) + bench("$$$ count/1", do: count(@big_tuple)) + bench("$$$ length/1", do: length(@big_tuple)) - bench "$$$ empty?/1", do: empty?(@big_tuple) - bench "$$$ null?/1", do: null?(@big_tuple) + bench("$$$ empty?/1", do: empty?(@big_tuple)) + bench("$$$ null?/1", do: null?(@big_tuple)) - bench "$$$ member?/2", do: member?(@big_tuple, 99) + bench("$$$ member?/2", do: member?(@big_tuple, 99)) - bench "$$$ max/1", do: max(@big_tuple) - bench "$$$ max/2", do: max(@big_tuple, by: fn(x, y) -> Integer.mod(x, 3) > y end) + bench("$$$ max/1", do: max(@big_tuple)) + bench("$$$ max/2", do: max(@big_tuple, by: fn x, y -> Integer.mod(x, 3) > y end)) - bench "$$$ min/1", do: min(@big_tuple) - bench "$$$ min/2", do: min(@big_tuple, by: fn(x, y) -> Integer.mod(x, 3) > y end) + bench("$$$ min/1", do: min(@big_tuple)) + bench("$$$ min/2", do: min(@big_tuple, by: fn x, y -> Integer.mod(x, 3) > y end)) - bench "$$$ sum/1", do: sum(@big_tuple) - bench "$$$ product/1", do: product(@big_tuple) + bench("$$$ sum/1", do: sum(@big_tuple)) + bench("$$$ product/1", do: product(@big_tuple)) bench "$$$ random/1" do random(@big_tuple) - true # get Benchfella to match on multiple runs + # get Benchfella to match on multiple runs + true end - bench "$$$ fold/1", do: fold(@big_tuple) - bench "$$$ fold_map/2", do: fold_map(@big_tuple, fn x -> {x, x + 1} end) + bench("$$$ fold/1", do: fold(@big_tuple)) + bench("$$$ fold_map/2", do: fold_map(@big_tuple, fn x -> {x, x + 1} end)) - bench "$$$ left_fold/2", do: left_fold(@big_tuple, fn(acc, x) -> {x + 1 , acc} end) - bench "$$$ left_fold/3", do: left_fold(@big_tuple, @big_tuple, fn(acc, x) -> {x + 1 , acc} end) + bench("$$$ left_fold/2", do: left_fold(@big_tuple, fn acc, x -> {x + 1, acc} end)) + bench("$$$ left_fold/3", do: left_fold(@big_tuple, @big_tuple, fn acc, x -> {x + 1, acc} end)) - bench "$$$ right_fold/3 + {}", do: right_fold(@big_tuple, {1, 2}, fn(x, acc) -> {x + 1, acc} end) - bench "$$$ right_fold/3", do: right_fold(@big_tuple, @big_tuple, fn(x, acc) -> {x + 1, acc} end) + bench("$$$ right_fold/3 + {}", do: right_fold(@big_tuple, {1, 2}, fn x, acc -> {x + 1, acc} end)) - bench "$$$ size/1", do: size(@big_tuple) + bench("$$$ right_fold/3", do: right_fold(@big_tuple, @big_tuple, fn x, acc -> {x + 1, acc} end)) - bench "$$$ then_sequence/1", do: then_sequence(@nested) + bench("$$$ size/1", do: size(@big_tuple)) - bench "$$$ to_list/1", do: to_list(@big_tuple) + bench("$$$ then_sequence/1", do: then_sequence(@nested)) + + bench("$$$ to_list/1", do: to_list(@big_tuple)) bench "$$$ then_traverse/2" do @med_tuple @@ -154,8 +162,9 @@ defmodule Witchcraft.Foldable.TupleBench do bench "$$$ then_through/2" do fn y -> Tuple.duplicate(y, 251) end - |> then_through(fn x -> Tuple.duplicate(x, 251) end - |> then_through(@med_tuple)) + |> then_through( + fn x -> Tuple.duplicate(x, 251) end + |> then_through(@med_tuple) + ) end - end diff --git a/bench/witchcraft/functor/function_bench.exs b/bench/witchcraft/functor/function_bench.exs index c87e49e..304dfce 100644 --- a/bench/witchcraft/functor/function_bench.exs +++ b/bench/witchcraft/functor/function_bench.exs @@ -12,7 +12,7 @@ defmodule Witchcraft.Functor.FunctionBench do # Data Types # # ---------- # - def fun(x), do: "#{inspect x}-#{inspect x}" + def fun(x), do: "#{inspect(x)}-#{inspect(x)}" # -------------- # # Test Functions # @@ -24,16 +24,16 @@ defmodule Witchcraft.Functor.FunctionBench do # Simple # ########## - bench "apply Functor", do: map(&fun/1, &twice/1).(1) - bench "inline apply composed", do: fn x -> x |> fun() |> twice() end.(1) + bench("apply Functor", do: map(&fun/1, &twice/1).(1)) + bench("inline apply composed", do: (fn x -> x |> fun() |> twice() end).(1)) - bench "inline application", do: 1 |> fun() |> twice() - bench "inline composition", do: fn x -> x |> fun() |> twice() end + bench("inline application", do: 1 |> fun() |> twice()) + bench("inline composition", do: fn x -> x |> fun() |> twice() end) bench "naive compose function" do - fn(f, g) -> - fn x -> x |> f.() |> g.() end - end.(&fun/1, &twice/1) + (fn f, g -> + fn x -> x |> f.() |> g.() end + end).(&fun/1, &twice/1) end ############## @@ -44,38 +44,37 @@ defmodule Witchcraft.Functor.FunctionBench do # Static # # ====== # - bench "map/2", do: map(&fun/1, &twice/1) - bench "across/2", do: across(&twice/1, &fun/1) - bench "replace/2", do: replace(&fun/1, 42) + bench("map/2", do: map(&fun/1, &twice/1)) + bench("across/2", do: across(&twice/1, &fun/1)) + bench("replace/2", do: replace(&fun/1, 42)) # ----- # # Async # # ----- # - bench "async_map/2", do: async_map(&fun/1, &twice/1) - bench "async_across/2", do: async_across(&twice/1, &fun/1) + bench("async_map/2", do: async_map(&fun/1, &twice/1)) + bench("async_across/2", do: async_across(&twice/1, &fun/1)) # ======= # # Curried # # ======= # - bench "lift/2", do: lift(&fun/1, &twice/1) - bench "over/2", do: over(&twice/1, &fun/1) + bench("lift/2", do: lift(&fun/1, &twice/1)) + bench("over/2", do: over(&twice/1, &fun/1)) # ------------- # # Async Curried # # ------------- # - bench "async_lift/2", do: async_lift(&fun/1, &twice/1) - bench "async_over/2", do: async_over(&twice/1, &fun/1) + bench("async_lift/2", do: async_lift(&fun/1, &twice/1)) + bench("async_over/2", do: async_over(&twice/1, &fun/1)) # --------- # # Operators # # --------- # - bench "~>/2", do: (&fun/1) ~> (&twice/1) - bench "<~/2", do: (&twice/1) <~ (&fun/1) - + bench("~>/2", do: (&fun/1) ~> (&twice/1)) + bench("<~/2", do: (&twice/1) <~ (&fun/1)) ######################## # Expensive Operations # @@ -90,13 +89,13 @@ defmodule Witchcraft.Functor.FunctionBench do # Sequential # # ---------- # - bench "$$$ map/2", do: map(&fun/1, &expensive/1) - bench "$$$ lift/2", do: lift(&fun/1, &expensive/1) + bench("$$$ map/2", do: map(&fun/1, &expensive/1)) + bench("$$$ lift/2", do: lift(&fun/1, &expensive/1)) # ----- # # Async # # ----- # - bench "$$$ async_map/2", do: async_map(&fun/1, &expensive/1) - bench "$$$ async_lift/2", do: async_lift(&fun/1, &expensive/1) + bench("$$$ async_map/2", do: async_map(&fun/1, &expensive/1)) + bench("$$$ async_lift/2", do: async_lift(&fun/1, &expensive/1)) end diff --git a/bench/witchcraft/functor/list_bench.exs b/bench/witchcraft/functor/list_bench.exs index eaea2f7..ccf97a3 100644 --- a/bench/witchcraft/functor/list_bench.exs +++ b/bench/witchcraft/functor/list_bench.exs @@ -24,7 +24,7 @@ defmodule Witchcraft.Functor.ListBench do # Enum # ######## - bench "Enum.map/2", do: Enum.map(@list, &square/1) + bench("Enum.map/2", do: Enum.map(@list, &square/1)) ############## # Witchcraft # @@ -34,38 +34,37 @@ defmodule Witchcraft.Functor.ListBench do # Static # # ====== # - bench "map/2", do: map(@list, &square/1) - bench "across/2", do: across(&square/1, @list) - bench "replace/2", do: replace(@list, 42) + bench("map/2", do: map(@list, &square/1)) + bench("across/2", do: across(&square/1, @list)) + bench("replace/2", do: replace(@list, 42)) # ----- # # Async # # ----- # - bench "async_map/2", do: async_map(@list, &square/1) - bench "async_across/2", do: async_across(&square/1, @list) + bench("async_map/2", do: async_map(@list, &square/1)) + bench("async_across/2", do: async_across(&square/1, @list)) # ======= # # Curried # # ======= # - bench "lift/2", do: lift(@list, &square/1) - bench "over/2", do: over(&square/1, @list) + bench("lift/2", do: lift(@list, &square/1)) + bench("over/2", do: over(&square/1, @list)) # ------------- # # Async Curried # # ------------- # - bench "async_lift/2", do: async_lift(@list, &square/1) - bench "async_over/2", do: async_over(&square/1, @list) + bench("async_lift/2", do: async_lift(@list, &square/1)) + bench("async_over/2", do: async_over(&square/1, @list)) # --------- # # Operators # # --------- # - bench "~>/2", do: @list ~> (&square/1) - bench "<~/2", do: (&square/1) <~ @list - + bench("~>/2", do: @list ~> (&square/1)) + bench("<~/2", do: (&square/1) <~ @list) ######################## # Expensive Operations # @@ -82,13 +81,13 @@ defmodule Witchcraft.Functor.ListBench do # Sequential # # ---------- # - bench "$$$ map/2", do: map(@small_list, &expensive/1) - bench "$$$ lift/2", do: lift(@small_list, &expensive/1) + bench("$$$ map/2", do: map(@small_list, &expensive/1)) + bench("$$$ lift/2", do: lift(@small_list, &expensive/1)) # ----- # # Async # # ----- # - bench "$$$ async_map/2", do: async_map(@small_list, &expensive/1) - bench "$$$ async_lift/2", do: async_lift(@small_list, &expensive/1) + bench("$$$ async_map/2", do: async_map(@small_list, &expensive/1)) + bench("$$$ async_lift/2", do: async_lift(@small_list, &expensive/1)) end diff --git a/bench/witchcraft/functor/map_bench.exs b/bench/witchcraft/functor/map_bench.exs index 49d55a3..58b62d4 100644 --- a/bench/witchcraft/functor/map_bench.exs +++ b/bench/witchcraft/functor/map_bench.exs @@ -5,7 +5,7 @@ defmodule Witchcraft.Functor.MapBench do use Witchcraft.Functor @list Enum.to_list(0..10_000) - @map @list |> Enum.zip(@list) |> Enum.into(%{}) + @map @list |> Enum.zip(@list) |> Enum.into(%{}) defp square(x), do: x * x @@ -13,7 +13,7 @@ defmodule Witchcraft.Functor.MapBench do # Enum # ######## - bench "Enum.map/2", do: @map |> Enum.map(fn {x, y} -> {x, y * y} end) |> Enum.into(%{}) + bench("Enum.map/2", do: @map |> Enum.map(fn {x, y} -> {x, y * y} end) |> Enum.into(%{})) ############## # Witchcraft # @@ -23,45 +23,45 @@ defmodule Witchcraft.Functor.MapBench do # Static # # ====== # - bench "map/2", do: map(@map, &square/1) - bench "across/2", do: across(&square/1, @map) + bench("map/2", do: map(@map, &square/1)) + bench("across/2", do: across(&square/1, @map)) - bench "replace/2", do: replace(@map, 42) + bench("replace/2", do: replace(@map, 42)) # ----- # # Async # # ----- # - bench "async_map/2", do: async_map(@map, &square/1) - bench "async_across/2", do: async_across(&square/1, @map) + bench("async_map/2", do: async_map(@map, &square/1)) + bench("async_across/2", do: async_across(&square/1, @map)) # ======= # # Curried # # ======= # - bench "lift/2", do: lift(@map, &square/1) - bench "over/2", do: over(&square/1, @map) + bench("lift/2", do: lift(@map, &square/1)) + bench("over/2", do: over(&square/1, @map)) # ------------- # # Async Curried # # ------------- # - bench "async_lift/2", do: async_lift(@map, &square/1) - bench "async_over/2", do: async_over(&square/1, @map) + bench("async_lift/2", do: async_lift(@map, &square/1)) + bench("async_over/2", do: async_over(&square/1, @map)) # --------- # # Operators # # --------- # - bench "~>/2", do: @map ~> (&square/1) - bench "<~/2", do: (&square/1) <~ @map + bench("~>/2", do: @map ~> (&square/1)) + bench("<~/2", do: (&square/1) <~ @map) ######################## # Expensive Operations # ######################## @small_list Enum.to_list(0..100) - @small_map @small_list |> Enum.zip(@list) |> Enum.into(%{}) + @small_map @small_list |> Enum.zip(@list) |> Enum.into(%{}) defp expensive(x) do Process.sleep(50) @@ -72,13 +72,13 @@ defmodule Witchcraft.Functor.MapBench do # Sequential # # ---------- # - bench "$$$ map/2", do: map(@small_map, &expensive/1) - bench "$$$ lift/2", do: lift(@small_map, &expensive/1) + bench("$$$ map/2", do: map(@small_map, &expensive/1)) + bench("$$$ lift/2", do: lift(@small_map, &expensive/1)) # ----- # # Async # # ----- # - bench "$$$ async_map/2", do: async_map(@small_map, &expensive/1) - bench "$$$ async_lift/2", do: async_lift(@small_map, &expensive/1) + bench("$$$ async_map/2", do: async_map(@small_map, &expensive/1)) + bench("$$$ async_lift/2", do: async_lift(@small_map, &expensive/1)) end diff --git a/bench/witchcraft/functor/tuple_bench.exs b/bench/witchcraft/functor/tuple_bench.exs index 1782fca..d2949e6 100644 --- a/bench/witchcraft/functor/tuple_bench.exs +++ b/bench/witchcraft/functor/tuple_bench.exs @@ -24,7 +24,7 @@ defmodule Witchcraft.Functor.TupleBench do # Enum # ######## - bench "Enum.map/2", do: @tuple |> Tuple.to_list() |> Enum.map(&square/1) |> List.to_tuple() + bench("Enum.map/2", do: @tuple |> Tuple.to_list() |> Enum.map(&square/1) |> List.to_tuple()) ############## # Witchcraft # @@ -34,38 +34,37 @@ defmodule Witchcraft.Functor.TupleBench do # Static # # ====== # - bench "map/2", do: map(@tuple, &square/1) - bench "across/2", do: across(&square/1, @tuple) - bench "replace/2", do: replace(@tuple, 42) + bench("map/2", do: map(@tuple, &square/1)) + bench("across/2", do: across(&square/1, @tuple)) + bench("replace/2", do: replace(@tuple, 42)) # ----- # # Async # # ----- # - bench "async_map/2", do: async_map(@tuple, &square/1) - bench "async_across/2", do: async_across(&square/1, @tuple) + bench("async_map/2", do: async_map(@tuple, &square/1)) + bench("async_across/2", do: async_across(&square/1, @tuple)) # ======= # # Curried # # ======= # - bench "lift/2", do: lift(@tuple, &square/1) - bench "over/2", do: over(&square/1, @tuple) + bench("lift/2", do: lift(@tuple, &square/1)) + bench("over/2", do: over(&square/1, @tuple)) # ------------- # # Async Curried # # ------------- # - bench "async_lift/2", do: async_lift(@tuple, &square/1) - bench "async_over/2", do: async_over(&square/1, @tuple) + bench("async_lift/2", do: async_lift(@tuple, &square/1)) + bench("async_over/2", do: async_over(&square/1, @tuple)) # --------- # # Operators # # --------- # - bench "~>/2", do: @tuple ~> (&square/1) - bench "<~/2", do: (&square/1) <~ @tuple - + bench("~>/2", do: @tuple ~> (&square/1)) + bench("<~/2", do: (&square/1) <~ @tuple) ######################## # Expensive Operations # @@ -82,13 +81,13 @@ defmodule Witchcraft.Functor.TupleBench do # Sequential # # ---------- # - bench "$$$ map/2", do: map(@small_tuple, &expensive/1) - bench "$$$ lift/2", do: lift(@small_tuple, &expensive/1) + bench("$$$ map/2", do: map(@small_tuple, &expensive/1)) + bench("$$$ lift/2", do: lift(@small_tuple, &expensive/1)) # ----- # # Async # # ----- # - bench "$$$ async_map/2", do: async_map(@small_tuple, &expensive/1) - bench "$$$ async_lift/2", do: async_lift(@small_tuple, &expensive/1) + bench("$$$ async_map/2", do: async_map(@small_tuple, &expensive/1)) + bench("$$$ async_lift/2", do: async_lift(@small_tuple, &expensive/1)) end diff --git a/bench/witchcraft/monad/function_bench.exs b/bench/witchcraft/monad/function_bench.exs index b99f96b..4a10e0b 100644 --- a/bench/witchcraft/monad/function_bench.exs +++ b/bench/witchcraft/monad/function_bench.exs @@ -13,7 +13,7 @@ defmodule Witchcraft.Monad.FunctionBench do # Data Types # # ---------- # - def fun(x), do: "#{inspect x}-#{inspect x}" + def fun(x), do: "#{inspect(x)}-#{inspect(x)}" ######### # Monad # @@ -52,13 +52,14 @@ defmodule Witchcraft.Monad.FunctionBench do end bench "async_draw/2" do - fn h ->h <|> h end - |> async_draw((fn f -> - fn g -> - f <|> g <|> g <|> f + fn h -> h <|> h end + |> async_draw( + fn f -> + fn g -> + f <|> g <|> g <|> f + end end - end - |> async_draw(&fun/1))) + |> async_draw(&fun/1) + ) end - end diff --git a/bench/witchcraft/monad/list_bench.exs b/bench/witchcraft/monad/list_bench.exs index 2f13ca0..6a6fb2b 100644 --- a/bench/witchcraft/monad/list_bench.exs +++ b/bench/witchcraft/monad/list_bench.exs @@ -45,11 +45,17 @@ defmodule Witchcraft.Monad.ListBench do end bench "async_draw/2" do - async_draw(fn a -> - async_draw(fn b -> - [a * b] - end, @list_b) - end, @list_a) + async_draw( + fn a -> + async_draw( + fn b -> + [a * b] + end, + @list_b + ) + end, + @list_a + ) end # ----- # @@ -59,6 +65,7 @@ defmodule Witchcraft.Monad.ListBench do bench "!!! Enum.flat_map/2" do Enum.flat_map(@list_a, fn a -> Process.sleep(50) + Enum.flat_map(@list_b, fn b -> Process.sleep(50) [a * b] @@ -69,6 +76,7 @@ defmodule Witchcraft.Monad.ListBench do bench "!!! chain/2" do chain(@list_a, fn a -> Process.sleep(50) + chain(@list_b, fn b -> Process.sleep(50) [a * b] @@ -77,18 +85,26 @@ defmodule Witchcraft.Monad.ListBench do end bench "!!! draw/2" do - draw(fn a -> - Process.sleep(50) - draw(fn b -> + draw( + fn a -> Process.sleep(50) - [a * b] - end, @list_b) - end, @list_a) + + draw( + fn b -> + Process.sleep(50) + [a * b] + end, + @list_b + ) + end, + @list_a + ) end bench "!!! async_chain/2" do async_chain(@list_a, fn a -> Process.sleep(50) + async_chain(@list_b, fn b -> Process.sleep(50) [a * b] @@ -97,13 +113,20 @@ defmodule Witchcraft.Monad.ListBench do end bench "!!! async_draw/2" do - async_draw(fn a -> - Process.sleep(50) - async_draw(fn b -> + async_draw( + fn a -> Process.sleep(50) - [a * b] - end, @list_b) - end, @list_a) + + async_draw( + fn b -> + Process.sleep(50) + [a * b] + end, + @list_b + ) + end, + @list_a + ) end # ---------- # @@ -128,5 +151,4 @@ defmodule Witchcraft.Monad.ListBench do return(a * b) end end - end diff --git a/bench/witchcraft/monad/tuple_bench.exs b/bench/witchcraft/monad/tuple_bench.exs index d59055f..a82efb6 100644 --- a/bench/witchcraft/monad/tuple_bench.exs +++ b/bench/witchcraft/monad/tuple_bench.exs @@ -45,11 +45,17 @@ defmodule Witchcraft.Monad.TupleBench do end bench "async_draw/2" do - async_draw(fn a -> - async_draw(fn b -> - {a * b, a} - end, @tuple_b) - end, @tuple_a) + async_draw( + fn a -> + async_draw( + fn b -> + {a * b, a} + end, + @tuple_b + ) + end, + @tuple_a + ) end # ----- # @@ -59,6 +65,7 @@ defmodule Witchcraft.Monad.TupleBench do bench "!!! chain/2" do chain(@tuple_a, fn a -> Process.sleep(50) + chain(@tuple_b, fn b -> Process.sleep(50) {a * b, a} @@ -67,18 +74,26 @@ defmodule Witchcraft.Monad.TupleBench do end bench "!!! draw/2" do - draw(fn a -> - Process.sleep(50) - draw(fn b -> + draw( + fn a -> Process.sleep(50) - {a * b, a} - end, @tuple_b) - end, @tuple_a) + + draw( + fn b -> + Process.sleep(50) + {a * b, a} + end, + @tuple_b + ) + end, + @tuple_a + ) end bench "!!! async_chain/2" do async_chain(@tuple_a, fn a -> Process.sleep(50) + async_chain(@tuple_b, fn b -> Process.sleep(50) {a * b, a} @@ -87,13 +102,20 @@ defmodule Witchcraft.Monad.TupleBench do end bench "!!! async_draw/2" do - async_draw(fn a -> - Process.sleep(50) - async_draw(fn b -> + async_draw( + fn a -> Process.sleep(50) - {a * b, a} - end, @tuple_b) - end, @tuple_a) + + async_draw( + fn b -> + Process.sleep(50) + {a * b, a} + end, + @tuple_b + ) + end, + @tuple_a + ) end # -------- # @@ -123,5 +145,4 @@ defmodule Witchcraft.Monad.TupleBench do return(a * b) end end - end diff --git a/bench/witchcraft/monoid/bitstring_bench.exs b/bench/witchcraft/monoid/bitstring_bench.exs index e2254f7..47c0cf5 100644 --- a/bench/witchcraft/monoid/bitstring_bench.exs +++ b/bench/witchcraft/monoid/bitstring_bench.exs @@ -18,16 +18,15 @@ defmodule Witchcraft.Monoid.BitStringBench do # Monoid # ########## - bench "empty/1", do: empty(@string) - bench "empty?/1", do: empty?(@string) + bench("empty/1", do: empty(@string)) + bench("empty?/1", do: empty?(@string)) # ---------- # # Large Data # # ---------- # - @big_list_a 0..100_000 |> Enum.to_list() |> inspect() - - bench "$$$ empty/1", do: empty(@string) - bench "$$$ empty?/1", do: empty?(@string) + @big_list_a 0..100_000 |> Enum.to_list() |> inspect() + bench("$$$ empty/1", do: empty(@string)) + bench("$$$ empty?/1", do: empty?(@string)) end diff --git a/bench/witchcraft/monoid/float_bench.exs b/bench/witchcraft/monoid/float_bench.exs index ea39011..b20ffe2 100644 --- a/bench/witchcraft/monoid/float_bench.exs +++ b/bench/witchcraft/monoid/float_bench.exs @@ -18,8 +18,8 @@ defmodule Witchcraft.Monoid.FloatBench do # Monoid # ########## - bench "empty/1", do: empty(@float) - bench "empty?/1", do: empty?(@float) + bench("empty/1", do: empty(@float)) + bench("empty?/1", do: empty?(@float)) # ---------- # # Large Data # @@ -27,7 +27,6 @@ defmodule Witchcraft.Monoid.FloatBench do @big_float 1_234_567_890.21347289 - bench "$$$ empty/1", do: empty(@float) - bench "$$$ empty?/1", do: empty?(@float) - + bench("$$$ empty/1", do: empty(@float)) + bench("$$$ empty?/1", do: empty?(@float)) end diff --git a/bench/witchcraft/monoid/function_bench.exs b/bench/witchcraft/monoid/function_bench.exs index 787d8a6..6b0173c 100644 --- a/bench/witchcraft/monoid/function_bench.exs +++ b/bench/witchcraft/monoid/function_bench.exs @@ -18,7 +18,6 @@ defmodule Witchcraft.Monoid.FunctionBench do # Monoid # ########## - bench "empty/1", do: empty(@fun) - bench "empty?/1", do: empty?(@fun) - + bench("empty/1", do: empty(@fun)) + bench("empty?/1", do: empty?(@fun)) end diff --git a/bench/witchcraft/monoid/integer_bench.exs b/bench/witchcraft/monoid/integer_bench.exs index ed6fdeb..f1663a5 100644 --- a/bench/witchcraft/monoid/integer_bench.exs +++ b/bench/witchcraft/monoid/integer_bench.exs @@ -18,8 +18,8 @@ defmodule Witchcraft.Monoid.IntegerBench do # Monoid # ########## - bench "empty/1", do: empty(@int) - bench "empty?/1", do: empty?(@int) + bench("empty/1", do: empty(@int)) + bench("empty?/1", do: empty?(@int)) # ---------- # # Large Data # @@ -27,7 +27,6 @@ defmodule Witchcraft.Monoid.IntegerBench do @big_int 1_234_567_890 - bench "$$$ empty/1", do: empty(@int) - bench "$$$ empty?/1", do: empty?(@int) - + bench("$$$ empty/1", do: empty(@int)) + bench("$$$ empty?/1", do: empty?(@int)) end diff --git a/bench/witchcraft/monoid/list_bench.exs b/bench/witchcraft/monoid/list_bench.exs index d871609..3307953 100644 --- a/bench/witchcraft/monoid/list_bench.exs +++ b/bench/witchcraft/monoid/list_bench.exs @@ -18,8 +18,8 @@ defmodule Witchcraft.Monoid.ListBench do # Monoid # ########## - bench "empty/1", do: empty(@list) - bench "empty?/1", do: empty?(@list) + bench("empty/1", do: empty(@list)) + bench("empty?/1", do: empty?(@list)) # ---------- # # Large Data # @@ -27,7 +27,6 @@ defmodule Witchcraft.Monoid.ListBench do @big_list 0..100_000 |> Enum.to_list() - bench "$$$ empty/1", do: empty(@big_list) - bench "$$$ empty?/1", do: empty?(@big_list) - + bench("$$$ empty/1", do: empty(@big_list)) + bench("$$$ empty?/1", do: empty?(@big_list)) end diff --git a/bench/witchcraft/monoid/map_bench.exs b/bench/witchcraft/monoid/map_bench.exs index 881cb7b..eab983a 100644 --- a/bench/witchcraft/monoid/map_bench.exs +++ b/bench/witchcraft/monoid/map_bench.exs @@ -13,23 +13,22 @@ defmodule Witchcraft.Monoid.MapBench do # ---------- # @list 0..10 |> Enum.to_list() - @map @list |> Enum.zip(@list) |> Enum.into(%{}) + @map @list |> Enum.zip(@list) |> Enum.into(%{}) ########## # Monoid # ########## - bench "empty/1", do: empty(@map) - bench "empty?/1", do: empty?(@map) + bench("empty/1", do: empty(@map)) + bench("empty?/1", do: empty?(@map)) # ---------- # # Large Data # # ---------- # @big_list 0..100_000 |> Enum.to_list() - @big_map @big_list |> Enum.zip(@big_list) |> Enum.into(%{}) - - bench "$$$ empty/1", do: empty(@big_map) - bench "$$$ empty?/1", do: empty?(@big_map) + @big_map @big_list |> Enum.zip(@big_list) |> Enum.into(%{}) + bench("$$$ empty/1", do: empty(@big_map)) + bench("$$$ empty?/1", do: empty?(@big_map)) end diff --git a/bench/witchcraft/monoid/map_set_bench.exs b/bench/witchcraft/monoid/map_set_bench.exs index 8bb86dc..b7c1858 100644 --- a/bench/witchcraft/monoid/map_set_bench.exs +++ b/bench/witchcraft/monoid/map_set_bench.exs @@ -18,8 +18,8 @@ defmodule Witchcraft.Monoid.MapSetBench do # Monoid # ########## - bench "empty/1", do: empty(@map_set) - bench "empty?/1", do: empty?(@map_set) + bench("empty/1", do: empty(@map_set)) + bench("empty?/1", do: empty?(@map_set)) # ---------- # # Large Data # @@ -27,7 +27,6 @@ defmodule Witchcraft.Monoid.MapSetBench do @big_map_set MapSet.new(0..100_000) - bench "$$$ empty/1", do: empty(@big_map_set) - bench "$$$ empty?/1", do: empty?(@big_map_set) - + bench("$$$ empty/1", do: empty(@big_map_set)) + bench("$$$ empty?/1", do: empty?(@big_map_set)) end diff --git a/bench/witchcraft/monoid/tuple_bench.exs b/bench/witchcraft/monoid/tuple_bench.exs index c94c15a..a3a4ae6 100644 --- a/bench/witchcraft/monoid/tuple_bench.exs +++ b/bench/witchcraft/monoid/tuple_bench.exs @@ -18,8 +18,8 @@ defmodule Witchcraft.Monoid.TupleBench do # Monoid # ########## - bench "empty/1", do: empty(@tuple) - bench "empty?/1", do: empty?(@tuple) + bench("empty/1", do: empty(@tuple)) + bench("empty?/1", do: empty?(@tuple)) # ---------- # # Large Data # @@ -27,7 +27,6 @@ defmodule Witchcraft.Monoid.TupleBench do @big_tuple 0..100_000 |> Enum.to_list() |> List.to_tuple() - bench "$$$ empty/1", do: empty(@big_tuple) - bench "$$$ empty?/1", do: empty?(@big_tuple) - + bench("$$$ empty/1", do: empty(@big_tuple)) + bench("$$$ empty?/1", do: empty?(@big_tuple)) end diff --git a/bench/witchcraft/ord/bitstring.exs b/bench/witchcraft/ord/bitstring.exs index 5a4c532..b3d5359 100644 --- a/bench/witchcraft/ord/bitstring.exs +++ b/bench/witchcraft/ord/bitstring.exs @@ -19,42 +19,42 @@ defmodule Witchcraft.Ord.BitStringBench do # Kernel # ########## - bench "Kernel.>/2", do: Kernel.>(@string_a, @string_b) - bench "Kernel./2", do: Kernel.>(@string_a, @string_b)) + bench("Kernel.=/2", do: Kernel.>=(@string_a, @string_b) - bench "Kernel.<=/2", do: Kernel.<=(@string_a, @string_b) + bench("Kernel.>=/2", do: Kernel.>=(@string_a, @string_b)) + bench("Kernel.<=/2", do: Kernel.<=(@string_a, @string_b)) ####### # Ord # ####### - bench "compare/2", do: compare(@string_a, @string_b) + bench("compare/2", do: compare(@string_a, @string_b)) - bench "equal?/2", do: equal?(@string_a, @string_b) - bench "greater?/2", do: greater?(@string_a, @string_b) - bench "lesser/2", do: lesser?(@string_a, @string_b) + bench("equal?/2", do: equal?(@string_a, @string_b)) + bench("greater?/2", do: greater?(@string_a, @string_b)) + bench("lesser/2", do: lesser?(@string_a, @string_b)) # --------- # # Operators # # --------- # - bench ">/2", do: @string_a > @string_b - bench "/2", do: @string_a > @string_b) + bench("=/2", do: @string_a >= @string_b - bench "<=/2", do: @string_a <= @string_b + bench(">=/2", do: @string_a >= @string_b) + bench("<=/2", do: @string_a <= @string_b) # ---------- # # Large Data # # ---------- # - @big_string_a 0..100_000 |> Enum.to_list() |> Enum.shuffle() |> inspect() + @big_string_a 0..100_000 |> Enum.to_list() |> Enum.shuffle() |> inspect() @big_string_b 99..999_999 |> Enum.to_list() |> Enum.shuffle() |> inspect() - bench "$$$ Kernel.>/2", do: Kernel.>(@big_string_a, @big_string_b) - bench "$$$ Kernel./2", do: Kernel.>(@big_string_a, @big_string_b)) + bench("$$$ Kernel./2", do: @big_string_a > @big_string_b + bench("$$$ /2", do: @big_string_a > @big_string_b) end diff --git a/bench/witchcraft/ord/float_bench.exs b/bench/witchcraft/ord/float_bench.exs index 83218a9..bb6906b 100644 --- a/bench/witchcraft/ord/float_bench.exs +++ b/bench/witchcraft/ord/float_bench.exs @@ -19,31 +19,31 @@ defmodule Witchcraft.Ord.FloatBench do # Kernel # ########## - bench "Kernel.>/2", do: Kernel.>(@float_a, @float_b) - bench "Kernel./2", do: Kernel.>(@float_a, @float_b)) + bench("Kernel.=/2", do: Kernel.>=(@float_a, @float_b) - bench "Kernel.<=/2", do: Kernel.<=(@float_a, @float_b) + bench("Kernel.>=/2", do: Kernel.>=(@float_a, @float_b)) + bench("Kernel.<=/2", do: Kernel.<=(@float_a, @float_b)) ####### # Ord # ####### - bench "compare/2", do: compare(@float_a, @float_b) + bench("compare/2", do: compare(@float_a, @float_b)) - bench "equal?/2", do: equal?(@float_a, @float_b) - bench "greater?/2", do: greater?(@float_a, @float_b) - bench "lesser/2", do: lesser?(@float_a, @float_b) + bench("equal?/2", do: equal?(@float_a, @float_b)) + bench("greater?/2", do: greater?(@float_a, @float_b)) + bench("lesser/2", do: lesser?(@float_a, @float_b)) # --------- # # Operators # # --------- # - bench ">/2", do: @float_a > @float_b - bench "/2", do: @float_a > @float_b) + bench("=/2", do: @float_a >= @float_b - bench "<=/2", do: @float_a <= @float_b + bench(">=/2", do: @float_a >= @float_b) + bench("<=/2", do: @float_a <= @float_b) # ---------- # # Large Data # @@ -52,9 +52,9 @@ defmodule Witchcraft.Ord.FloatBench do @big_float_a 1_234_567.890 @big_float_b 9_876.543210 - bench "$$$ Kernel.>/2", do: Kernel.>(@big_float_a, @big_float_b) - bench "$$$ Kernel./2", do: Kernel.>(@big_float_a, @big_float_b)) + bench("$$$ Kernel./2", do: @big_float_a > @big_float_b + bench("$$$ /2", do: @big_float_a > @big_float_b) end diff --git a/bench/witchcraft/ord/integer_bench.exs b/bench/witchcraft/ord/integer_bench.exs index 3a92a63..d6d309c 100644 --- a/bench/witchcraft/ord/integer_bench.exs +++ b/bench/witchcraft/ord/integer_bench.exs @@ -19,31 +19,31 @@ defmodule Witchcraft.Ord.IntegerBench do # Kernel # ########## - bench "Kernel.>/2", do: Kernel.>(@int_a, @int_b) - bench "Kernel./2", do: Kernel.>(@int_a, @int_b)) + bench("Kernel.=/2", do: Kernel.>=(@int_a, @int_b) - bench "Kernel.<=/2", do: Kernel.<=(@int_a, @int_b) + bench("Kernel.>=/2", do: Kernel.>=(@int_a, @int_b)) + bench("Kernel.<=/2", do: Kernel.<=(@int_a, @int_b)) ####### # Ord # ####### - bench "compare/2", do: compare(@int_a, @int_b) + bench("compare/2", do: compare(@int_a, @int_b)) - bench "equal?/2", do: equal?(@int_a, @int_b) - bench "greater?/2", do: greater?(@int_a, @int_b) - bench "lesser/2", do: lesser?(@int_a, @int_b) + bench("equal?/2", do: equal?(@int_a, @int_b)) + bench("greater?/2", do: greater?(@int_a, @int_b)) + bench("lesser/2", do: lesser?(@int_a, @int_b)) # --------- # # Operators # # --------- # - bench ">/2", do: @int_a > @int_b - bench "/2", do: @int_a > @int_b) + bench("=/2", do: @int_a >= @int_b - bench "<=/2", do: @int_a <= @int_b + bench(">=/2", do: @int_a >= @int_b) + bench("<=/2", do: @int_a <= @int_b) # ---------- # # Large Data # @@ -52,9 +52,9 @@ defmodule Witchcraft.Ord.IntegerBench do @big_int_a 1_234_567_890 @big_int_b 9_876_543_210 - bench "$$$ Kernel.>/2", do: Kernel.>(@big_int_a, @big_int_b) - bench "$$$ Kernel./2", do: Kernel.>(@big_int_a, @big_int_b)) + bench("$$$ Kernel./2", do: @big_int_a > @big_int_b + bench("$$$ /2", do: @big_int_a > @big_int_b) end diff --git a/bench/witchcraft/ord/list_bench.exs b/bench/witchcraft/ord/list_bench.exs index df5cf5a..a8ee721 100644 --- a/bench/witchcraft/ord/list_bench.exs +++ b/bench/witchcraft/ord/list_bench.exs @@ -19,42 +19,42 @@ defmodule Witchcraft.Ord.ListBench do # Kernel # ########## - bench "Kernel.>/2", do: Kernel.>(@list_a, @list_b) - bench "Kernel./2", do: Kernel.>(@list_a, @list_b)) + bench("Kernel.=/2", do: Kernel.>=(@list_a, @list_b) - bench "Kernel.<=/2", do: Kernel.<=(@list_a, @list_b) + bench("Kernel.>=/2", do: Kernel.>=(@list_a, @list_b)) + bench("Kernel.<=/2", do: Kernel.<=(@list_a, @list_b)) ####### # Ord # ####### - bench "compare/2", do: compare(@list_a, @list_b) + bench("compare/2", do: compare(@list_a, @list_b)) - bench "equal?/2", do: equal?(@list_a, @list_b) - bench "greater?/2", do: greater?(@list_a, @list_b) - bench "lesser/2", do: lesser?(@list_a, @list_b) + bench("equal?/2", do: equal?(@list_a, @list_b)) + bench("greater?/2", do: greater?(@list_a, @list_b)) + bench("lesser/2", do: lesser?(@list_a, @list_b)) # --------- # # Operators # # --------- # - bench ">/2", do: @list_a > @list_b - bench "/2", do: @list_a > @list_b) + bench("=/2", do: @list_a >= @list_b - bench "<=/2", do: @list_a <= @list_b + bench(">=/2", do: @list_a >= @list_b) + bench("<=/2", do: @list_a <= @list_b) # ---------- # # Large Data # # ---------- # - @big_list_a 0..100_000 |> Enum.to_list() |> Enum.shuffle() + @big_list_a 0..100_000 |> Enum.to_list() |> Enum.shuffle() @big_list_b 99..999_999 |> Enum.to_list() |> Enum.shuffle() - bench "$$$ Kernel.>/2", do: Kernel.>(@big_list_a, @big_list_b) - bench "$$$ Kernel./2", do: Kernel.>(@big_list_a, @big_list_b)) + bench("$$$ Kernel./2", do: @big_list_a > @big_list_b + bench("$$$ /2", do: @big_list_a > @big_list_b) end diff --git a/bench/witchcraft/ord/map_bench.exs b/bench/witchcraft/ord/map_bench.exs index 9e6b3a5..8f9e4c2 100644 --- a/bench/witchcraft/ord/map_bench.exs +++ b/bench/witchcraft/ord/map_bench.exs @@ -22,45 +22,45 @@ defmodule Witchcraft.Ord.MapBench do # Kernel # ########## - bench "Kernel.>/2", do: Kernel.>(@map_a, @map_b) - bench "Kernel./2", do: Kernel.>(@map_a, @map_b)) + bench("Kernel.=/2", do: Kernel.>=(@map_a, @map_b) - bench "Kernel.<=/2", do: Kernel.<=(@map_a, @map_b) + bench("Kernel.>=/2", do: Kernel.>=(@map_a, @map_b)) + bench("Kernel.<=/2", do: Kernel.<=(@map_a, @map_b)) ####### # Ord # ####### - bench "compare/2", do: compare(@map_a, @map_b) + bench("compare/2", do: compare(@map_a, @map_b)) - bench "equal?/2", do: equal?(@map_a, @map_b) - bench "greater?/2", do: greater?(@map_a, @map_b) - bench "lesser/2", do: lesser?(@map_a, @map_b) + bench("equal?/2", do: equal?(@map_a, @map_b)) + bench("greater?/2", do: greater?(@map_a, @map_b)) + bench("lesser/2", do: lesser?(@map_a, @map_b)) # --------- # # Operators # # --------- # - bench ">/2", do: @map_a > @map_b - bench "/2", do: @map_a > @map_b) + bench("=/2", do: @map_a >= @map_b - bench "<=/2", do: @map_a <= @map_b + bench(">=/2", do: @map_a >= @map_b) + bench("<=/2", do: @map_a <= @map_b) # ---------- # # Large Data # # ---------- # - @big_list_a 0..100_000 |> Enum.to_list() |> Enum.shuffle() + @big_list_a 0..100_000 |> Enum.to_list() |> Enum.shuffle() @big_list_b 99..999_999 |> Enum.to_list() |> Enum.shuffle() @big_map_a @big_list_a |> Enum.zip(@list_b) |> Enum.into(%{}) @big_map_b @big_list_b |> Enum.zip(@list_a) |> Enum.into(%{}) - bench "$$$ Kernel.>/2", do: Kernel.>(@big_map_a, @big_map_b) - bench "$$$ Kernel./2", do: Kernel.>(@big_map_a, @big_map_b)) + bench("$$$ Kernel./2", do: @big_map_a > @big_map_b + bench("$$$ /2", do: @big_map_a > @big_map_b) end diff --git a/bench/witchcraft/ord/tuple_bench.exs b/bench/witchcraft/ord/tuple_bench.exs index 09769d8..fbe89f0 100644 --- a/bench/witchcraft/ord/tuple_bench.exs +++ b/bench/witchcraft/ord/tuple_bench.exs @@ -19,42 +19,42 @@ defmodule Witchcraft.Ord.TupleBench do # Kernel # ########## - bench "Kernel.>/2", do: Kernel.>(@tuple_a, @tuple_b) - bench "Kernel./2", do: Kernel.>(@tuple_a, @tuple_b)) + bench("Kernel.=/2", do: Kernel.>=(@tuple_a, @tuple_b) - bench "Kernel.<=/2", do: Kernel.<=(@tuple_a, @tuple_b) + bench("Kernel.>=/2", do: Kernel.>=(@tuple_a, @tuple_b)) + bench("Kernel.<=/2", do: Kernel.<=(@tuple_a, @tuple_b)) ####### # Ord # ####### - bench "compare/2", do: compare(@tuple_a, @tuple_b) + bench("compare/2", do: compare(@tuple_a, @tuple_b)) - bench "equal?/2", do: equal?(@tuple_a, @tuple_b) - bench "greater?/2", do: greater?(@tuple_a, @tuple_b) - bench "lesser/2", do: lesser?(@tuple_a, @tuple_b) + bench("equal?/2", do: equal?(@tuple_a, @tuple_b)) + bench("greater?/2", do: greater?(@tuple_a, @tuple_b)) + bench("lesser/2", do: lesser?(@tuple_a, @tuple_b)) # --------- # # Operators # # --------- # - bench ">/2", do: @tuple_a > @tuple_b - bench "/2", do: @tuple_a > @tuple_b) + bench("=/2", do: @tuple_a >= @tuple_b - bench "<=/2", do: @tuple_a <= @tuple_b + bench(">=/2", do: @tuple_a >= @tuple_b) + bench("<=/2", do: @tuple_a <= @tuple_b) # ---------- # # Large Data # # ---------- # - @big_tuple_a 0..100_000 |> Enum.to_list() |> Enum.shuffle() |> List.to_tuple() + @big_tuple_a 0..100_000 |> Enum.to_list() |> Enum.shuffle() |> List.to_tuple() @big_tuple_b 99..999_999 |> Enum.to_list() |> Enum.shuffle() |> List.to_tuple() - bench "$$$ Kernel.>/2", do: Kernel.>(@big_tuple_a, @big_tuple_b) - bench "$$$ Kernel./2", do: Kernel.>(@big_tuple_a, @big_tuple_b)) + bench("$$$ Kernel./2", do: @big_tuple_a > @big_tuple_b + bench("$$$ /2", do: @big_tuple_a > @big_tuple_b) end diff --git a/bench/witchcraft/semigroup/bitstring_bench.exs b/bench/witchcraft/semigroup/bitstring_bench.exs index 3af33e7..ce4af70 100644 --- a/bench/witchcraft/semigroup/bitstring_bench.exs +++ b/bench/witchcraft/semigroup/bitstring_bench.exs @@ -19,30 +19,29 @@ defmodule Witchcraft.Semigroup.BitStringBench do # Kernel # ########## - bench "Kernel.<>/2", do: @string_a <> @string_b + bench("Kernel.<>/2", do: @string_a <> @string_b) ############# # Semigroup # ############# - bench "append/2", do: append(@string_a, @string_b) - bench "repeat/2", do: repeat(@string_a, times: 100) + bench("append/2", do: append(@string_a, @string_b)) + bench("repeat/2", do: repeat(@string_a, times: 100)) # --------- # # Operators # # --------- # - bench "<>/2", do: @string_a <> @string_b + bench("<>/2", do: @string_a <> @string_b) # ---------- # # Large Data # # ---------- # - @big_string_a 0..100_000 |> Enum.to_list() |> Enum.shuffle() |> inspect() + @big_string_a 0..100_000 |> Enum.to_list() |> Enum.shuffle() |> inspect() @big_string_b 99..999_999 |> Enum.to_list() |> Enum.shuffle() |> inspect() - bench "$$$ Kernel.<>/2", do: @big_string_a <> @big_string_b - bench "$$$ append/2", do: append(@big_string_a, @big_string_b) - bench "$$$ <>/2", do: @big_string_a <> @big_string_b - + bench("$$$ Kernel.<>/2", do: @big_string_a <> @big_string_b) + bench("$$$ append/2", do: append(@big_string_a, @big_string_b)) + bench("$$$ <>/2", do: @big_string_a <> @big_string_b) end diff --git a/bench/witchcraft/semigroup/float_bench.exs b/bench/witchcraft/semigroup/float_bench.exs index 77ab9ab..ff6d210 100644 --- a/bench/witchcraft/semigroup/float_bench.exs +++ b/bench/witchcraft/semigroup/float_bench.exs @@ -19,20 +19,20 @@ defmodule Witchcraft.Semigroup.FloatBench do # Kernel # ########## - bench "Kernel.+/2", do: @float_a + @float_b + bench("Kernel.+/2", do: @float_a + @float_b) ############# # Semigroup # ############# - bench "append/2", do: append(@float_a, @float_b) - bench "repeat/2", do: repeat(@float_a, times: 100) + bench("append/2", do: append(@float_a, @float_b)) + bench("repeat/2", do: repeat(@float_a, times: 100)) # --------- # # Operators # # --------- # - bench "<>/2", do: @float_a <> @float_b + bench("<>/2", do: @float_a <> @float_b) # ---------- # # Large Data # @@ -41,8 +41,7 @@ defmodule Witchcraft.Semigroup.FloatBench do @big_float_a 1_234_567.890 @big_float_b 9_876.6543210 - bench "$$$ Kernel.+/2", do: @big_float_a + @big_float_b - bench "$$$ append/2", do: append(@big_float_a, @big_float_b) - bench "$$$ <>/2", do: @big_float_a <> @big_float_b - + bench("$$$ Kernel.+/2", do: @big_float_a + @big_float_b) + bench("$$$ append/2", do: append(@big_float_a, @big_float_b)) + bench("$$$ <>/2", do: @big_float_a <> @big_float_b) end diff --git a/bench/witchcraft/semigroup/function_bench.exs b/bench/witchcraft/semigroup/function_bench.exs index 128bfd0..bd451da 100644 --- a/bench/witchcraft/semigroup/function_bench.exs +++ b/bench/witchcraft/semigroup/function_bench.exs @@ -12,7 +12,7 @@ defmodule Witchcraft.Semigroup.FunctionBench do # Data Types # # ---------- # - def fun(x), do: "#{inspect x}-#{inspect x}" + def fun(x), do: "#{inspect(x)}-#{inspect(x)}" # -------------- # # Test Functions # @@ -25,22 +25,21 @@ defmodule Witchcraft.Semigroup.FunctionBench do ########## bench "naive compose function" do - fn(f, g) -> - fn x -> x |> f.() |> g.() end - end.(&fun/1, &twice/1) + (fn f, g -> + fn x -> x |> f.() |> g.() end + end).(&fun/1, &twice/1) end ############# # Semigroup # ############# - bench "append/2", do: append(&fun/1, &twice/1) - bench "repeat/2", do: repeat(&fun/1, times: 100) + bench("append/2", do: append(&fun/1, &twice/1)) + bench("repeat/2", do: repeat(&fun/1, times: 100)) # --------- # # Operators # # --------- # - bench "<>/2", do: (&fun/1) <> (&twice/1) - + bench("<>/2", do: (&fun/1) <> &twice/1) end diff --git a/bench/witchcraft/semigroup/integer_bench.exs b/bench/witchcraft/semigroup/integer_bench.exs index 3f379da..2173fab 100644 --- a/bench/witchcraft/semigroup/integer_bench.exs +++ b/bench/witchcraft/semigroup/integer_bench.exs @@ -19,20 +19,20 @@ defmodule Witchcraft.Semigroup.IntegerBench do # Kernel # ########## - bench "Kernel.+/2", do: @int_a + @int_b + bench("Kernel.+/2", do: @int_a + @int_b) ############# # Semigroup # ############# - bench "append/2", do: append(@int_a, @int_b) - bench "repeat/2", do: repeat(@int_a, times: 100) + bench("append/2", do: append(@int_a, @int_b)) + bench("repeat/2", do: repeat(@int_a, times: 100)) # --------- # # Operators # # --------- # - bench "<>/2", do: @int_a <> @int_b + bench("<>/2", do: @int_a <> @int_b) # ---------- # # Large Data # @@ -41,8 +41,7 @@ defmodule Witchcraft.Semigroup.IntegerBench do @big_int_a 1_234_567_890 @big_int_b 9_876_543_210 - bench "$$$ Kernel.+/2", do: @big_int_a + @big_int_b - bench "$$$ append/2", do: append(@big_int_a, @big_int_b) - bench "$$$ <>/2", do: @big_int_a <> @big_int_b - + bench("$$$ Kernel.+/2", do: @big_int_a + @big_int_b) + bench("$$$ append/2", do: append(@big_int_a, @big_int_b)) + bench("$$$ <>/2", do: @big_int_a <> @big_int_b) end diff --git a/bench/witchcraft/semigroup/list_bench.exs b/bench/witchcraft/semigroup/list_bench.exs index 2911d8d..d5d2d9a 100644 --- a/bench/witchcraft/semigroup/list_bench.exs +++ b/bench/witchcraft/semigroup/list_bench.exs @@ -19,30 +19,29 @@ defmodule Witchcraft.Semigroup.ListBench do # Kernel # ########## - bench "Kernel.++/2", do: @list_a ++ @list_b + bench("Kernel.++/2", do: @list_a ++ @list_b) ############# # Semigroup # ############# - bench "append/2", do: append(@list_a, @list_b) - bench "repeat/2", do: repeat(@list_a, times: 100) + bench("append/2", do: append(@list_a, @list_b)) + bench("repeat/2", do: repeat(@list_a, times: 100)) # --------- # # Operators # # --------- # - bench "<>/2", do: @list_a <> @list_b + bench("<>/2", do: @list_a <> @list_b) # ---------- # # Large Data # # ---------- # - @big_list_a 0..100_000 |> Enum.to_list() |> Enum.shuffle() + @big_list_a 0..100_000 |> Enum.to_list() |> Enum.shuffle() @big_list_b 99..999_999 |> Enum.to_list() |> Enum.shuffle() - bench "$$$ Kernel.++/2", do: @big_list_a ++ @big_list_b - bench "$$$ append/2", do: append(@big_list_a, @big_list_b) - bench "$$$ <>/2", do: @big_list_a <> @big_list_b - + bench("$$$ Kernel.++/2", do: @big_list_a ++ @big_list_b) + bench("$$$ append/2", do: append(@big_list_a, @big_list_b)) + bench("$$$ <>/2", do: @big_list_a <> @big_list_b) end diff --git a/bench/witchcraft/semigroup/map_bench.exs b/bench/witchcraft/semigroup/map_bench.exs index b4aeeed..be8dc31 100644 --- a/bench/witchcraft/semigroup/map_bench.exs +++ b/bench/witchcraft/semigroup/map_bench.exs @@ -22,33 +22,32 @@ defmodule Witchcraft.Semigroup.MapBench do # Map # ####### - bench "Map.merge/2", do: Map.merge(@map_a, @map_b) + bench("Map.merge/2", do: Map.merge(@map_a, @map_b)) ############# # Semigroup # ############# - bench "append/2", do: append(@map_a, @map_b) - bench "repeat/2", do: repeat(@map_a, times: 100) + bench("append/2", do: append(@map_a, @map_b)) + bench("repeat/2", do: repeat(@map_a, times: 100)) # --------- # # Operators # # --------- # - bench "<>/2", do: @map_a <> @map_b + bench("<>/2", do: @map_a <> @map_b) # ---------- # # Large Data # # ---------- # - @big_list_a 0..100_000 |> Enum.to_list() |> Enum.shuffle() + @big_list_a 0..100_000 |> Enum.to_list() |> Enum.shuffle() @big_list_b 99..999_999 |> Enum.to_list() |> Enum.shuffle() @big_map_a @big_list_a |> Enum.zip(@list_b) |> Enum.into(%{}) @big_map_b @big_list_b |> Enum.zip(@list_a) |> Enum.into(%{}) - bench "$$$ Map.merge/2", do: Map.merge(@big_map_a, @big_map_b) - bench "$$$ append/2", do: append(@big_map_a, @big_map_b) - bench "$$$ <>/2", do: @big_map_a <> @big_map_b - + bench("$$$ Map.merge/2", do: Map.merge(@big_map_a, @big_map_b)) + bench("$$$ append/2", do: append(@big_map_a, @big_map_b)) + bench("$$$ <>/2", do: @big_map_a <> @big_map_b) end diff --git a/bench/witchcraft/semigroup/mapset_bench 2.exs b/bench/witchcraft/semigroup/mapset_bench 2.exs index 827f57e..2a29555 100644 --- a/bench/witchcraft/semigroup/mapset_bench 2.exs +++ b/bench/witchcraft/semigroup/mapset_bench 2.exs @@ -19,20 +19,20 @@ defmodule Witchcraft.Semigroup.MapBench do # MapSet # ########## - bench "MapSet.union/2", do: MapSet.union(@map_set_a, @map_set_b) + bench("MapSet.union/2", do: MapSet.union(@map_set_a, @map_set_b)) ############# # Semigroup # ############# - bench "append/2", do: append(@map_set_a, @map_set_b) - bench "repeat/2", do: repeat(@map_set_a, times: 100) + bench("append/2", do: append(@map_set_a, @map_set_b)) + bench("repeat/2", do: repeat(@map_set_a, times: 100)) # --------- # # Operators # # --------- # - bench "<>/2", do: @map_set_a <> @map_set_b + bench("<>/2", do: @map_set_a <> @map_set_b) # ---------- # # Large Data # @@ -41,8 +41,7 @@ defmodule Witchcraft.Semigroup.MapBench do @big_map_set_a MapSet.new(0..1_000) @big_map_set_b MapSet.new(99..999) - bench "$$$ MapSet.union/2", do: MapSet.union(@big_mapset_a, @big_mapset_b) - bench "$$$ append/2", do: append(@big_mapset_a, @big_mapset_b) - bench "$$$ <>/2", do: @big_mapset_a <> @big_mapset_b - + bench("$$$ MapSet.union/2", do: MapSet.union(@big_mapset_a, @big_mapset_b)) + bench("$$$ append/2", do: append(@big_mapset_a, @big_mapset_b)) + bench("$$$ <>/2", do: @big_mapset_a <> @big_mapset_b) end diff --git a/bench/witchcraft/semigroup/mapset_bench.exs b/bench/witchcraft/semigroup/mapset_bench.exs index a5f3ee2..f511fe8 100644 --- a/bench/witchcraft/semigroup/mapset_bench.exs +++ b/bench/witchcraft/semigroup/mapset_bench.exs @@ -19,20 +19,20 @@ defmodule Witchcraft.Semigroup.MapSetBench do # MapSet # ########## - bench "MapSet.union/2", do: MapSet.union(@map_set_a, @map_set_b) + bench("MapSet.union/2", do: MapSet.union(@map_set_a, @map_set_b)) ############# # Semigroup # ############# - bench "append/2", do: append(@map_set_a, @map_set_b) - bench "repeat/2", do: repeat(@map_set_a, times: 100) + bench("append/2", do: append(@map_set_a, @map_set_b)) + bench("repeat/2", do: repeat(@map_set_a, times: 100)) # --------- # # Operators # # --------- # - bench "<>/2", do: @map_set_a <> @map_set_b + bench("<>/2", do: @map_set_a <> @map_set_b) # ---------- # # Large Data # @@ -41,8 +41,7 @@ defmodule Witchcraft.Semigroup.MapSetBench do @big_map_set_a MapSet.new(0..1_000) @big_map_set_b MapSet.new(99..999) - bench "$$$ MapSet.union/2", do: MapSet.union(@big_map_set_a, @big_map_set_b) - bench "$$$ append/2", do: append(@big_map_set_a, @big_map_set_b) - bench "$$$ <>/2", do: @big_map_set_a <> @big_map_set_b - + bench("$$$ MapSet.union/2", do: MapSet.union(@big_map_set_a, @big_map_set_b)) + bench("$$$ append/2", do: append(@big_map_set_a, @big_map_set_b)) + bench("$$$ <>/2", do: @big_map_set_a <> @big_map_set_b) end diff --git a/bench/witchcraft/semigroup/tuple_bench.exs b/bench/witchcraft/semigroup/tuple_bench.exs index 1dde025..bcc7ddf 100644 --- a/bench/witchcraft/semigroup/tuple_bench.exs +++ b/bench/witchcraft/semigroup/tuple_bench.exs @@ -19,23 +19,22 @@ defmodule Witchcraft.Semigroup.TupleBench do # Semigroup # ############# - bench "append/2", do: append(@tuple_a, @tuple_b) - bench "repeat/2", do: repeat(@tuple_a, times: 100) + bench("append/2", do: append(@tuple_a, @tuple_b)) + bench("repeat/2", do: repeat(@tuple_a, times: 100)) # --------- # # Operators # # --------- # - bench "<>/2", do: @tuple_a <> @tuple_b + bench("<>/2", do: @tuple_a <> @tuple_b) # ---------- # # Large Data # # ---------- # - @big_tuple_a 0..100_000 |> Enum.to_list() |> Enum.shuffle() |> List.to_tuple() - @big_tuple_b 1..100_001 |> Enum.to_list() |> Enum.shuffle() |> List.to_tuple() - - bench "$$$ append/2", do: append(@big_tuple_a, @big_tuple_b) - bench "$$$ <>/2", do: @big_tuple_a <> @big_tuple_b + @big_tuple_a 0..100_000 |> Enum.to_list() |> Enum.shuffle() |> List.to_tuple() + @big_tuple_b 1..100_001 |> Enum.to_list() |> Enum.shuffle() |> List.to_tuple() + bench("$$$ append/2", do: append(@big_tuple_a, @big_tuple_b)) + bench("$$$ <>/2", do: @big_tuple_a <> @big_tuple_b) end diff --git a/bench/witchcraft/semigroupoid/function_bench.exs b/bench/witchcraft/semigroupoid/function_bench.exs index 4649230..f617c7a 100644 --- a/bench/witchcraft/semigroupoid/function_bench.exs +++ b/bench/witchcraft/semigroupoid/function_bench.exs @@ -12,42 +12,41 @@ defmodule Witchcraft.Semigroupoid.FunctionBench do # Data Types # # ---------- # - def f(x), do: "#{inspect x}/#{inspect x}" - def g(y), do: "#{inspect y}-#{inspect y}-#{inspect y}" + def f(x), do: "#{inspect(x)}/#{inspect(x)}" + def g(y), do: "#{inspect(y)}-#{inspect(y)}-#{inspect(y)}" ########## # Simple # ########## - bench "inline apply composed", do: fn x -> x |> f() |> g() end.(1) - bench "inline application", do: 1 |> f() |> g() + bench("inline apply composed", do: (fn x -> x |> f() |> g() end).(1)) + bench("inline application", do: 1 |> f() |> g()) - bench "inline composition", do: fn x -> x |> f() |> g() end + bench("inline composition", do: fn x -> x |> f() |> g() end) bench "naive compose function" do - fn(a, b) -> - fn c -> c |> a.() |> b.() end - end.(&f/1, &g/1) + (fn a, b -> + fn c -> c |> a.() |> b.() end + end).(&f/1, &g/1) end ################ # Semigroupoid # ################ - bench "apply/2", do: apply(&f/1, [1]) - bench "compose/2", do: compose(&f/1, &g/1) + bench("apply/2", do: apply(&f/1, [1])) + bench("compose/2", do: compose(&f/1, &g/1)) # --------- # # Operators # # --------- # - bench "<|>/2", do: (&g/1) <|> (&f/1) - bench "<~>/2", do: (&f/1) <~> (&g/1) + bench("<|>/2", do: (&g/1) <|> (&f/1)) + bench("<~>/2", do: (&f/1) <~> (&g/1)) - bench "direct <|>/2", do: ((&g/1) <|> (&f/1)).(1) - bench "direct <~>/2", do: 1 |> ((&f/1) <~> (&g/1)).() - - bench "apply <|>/2", do: apply((&g/1) <|> (&f/1), [1]) - bench "apply <~>/2", do: apply((&f/1) <~> (&g/1), [1]) + bench("direct <|>/2", do: ((&g/1) <|> (&f/1)).(1)) + bench("direct <~>/2", do: 1 |> ((&f/1) <~> (&g/1)).()) + bench("apply <|>/2", do: apply((&g/1) <|> (&f/1), [1])) + bench("apply <~>/2", do: apply((&f/1) <~> (&g/1), [1])) end diff --git a/bench/witchcraft/setoid/bitstring_bench.exs b/bench/witchcraft/setoid/bitstring_bench.exs index 0fa845b..43bd65c 100644 --- a/bench/witchcraft/setoid/bitstring_bench.exs +++ b/bench/witchcraft/setoid/bitstring_bench.exs @@ -19,42 +19,38 @@ defmodule Witchcraft.Setoid.BitStringBench do # Kernel # ########## - bench "Kernel.==/2", do: Kernel.==(@string_a, @string_b) - bench "Kernel.!=/2", do: Kernel.!=(@string_a, @string_b) + bench("Kernel.==/2", do: Kernel.==(@string_a, @string_b)) + bench("Kernel.!=/2", do: Kernel.!=(@string_a, @string_b)) ########## # Setoid # ########## - bench "equivalent?/2", do: equivalent?(@string_a, @string_b) - bench "nonequivalent?/2", do: nonequivalent?(@string_a, @string_b) + bench("equivalent?/2", do: equivalent?(@string_a, @string_b)) + bench("nonequivalent?/2", do: nonequivalent?(@string_a, @string_b)) # --------- # # Operators # # --------- # - bench "==/2", do: @string_a == @string_b - bench "!=/2", do: @string_a != @string_b + bench("==/2", do: @string_a == @string_b) + bench("!=/2", do: @string_a != @string_b) # ---------- # # Large Data # # ---------- # - @big_string_a ( - fn -> Enum.random(["hhh", "k", "8", "hello", "ください", "z", "?:!"]) end - |> Stream.repeatedly() - |> Enum.take(:rand.uniform(10_000)) - ) + @big_string_a fn -> Enum.random(["hhh", "k", "8", "hello", "ください", "z", "?:!"]) end + |> Stream.repeatedly() + |> Enum.take(:rand.uniform(10_000)) - @big_string_b ( - fn -> Enum.random(["abc", "z", "please", "!", "パン", "sure", "&"]) end - |> Stream.repeatedly() - |> Enum.take(:rand.uniform(10_000)) - ) + @big_string_b fn -> Enum.random(["abc", "z", "please", "!", "パン", "sure", "&"]) end + |> Stream.repeatedly() + |> Enum.take(:rand.uniform(10_000)) - bench "$$$ Kernel.==/2", do: Kernel.==(@big_string_a, @big_string_b) - bench "$$$ Kernel.!=/2", do: Kernel.!=(@big_string_a, @big_string_b) + bench("$$$ Kernel.==/2", do: Kernel.==(@big_string_a, @big_string_b)) + bench("$$$ Kernel.!=/2", do: Kernel.!=(@big_string_a, @big_string_b)) - bench "$$$ ==/2", do: @big_string_a == @big_string_b - bench "$$$ !=/2", do: @big_string_a != @big_string_b + bench("$$$ ==/2", do: @big_string_a == @big_string_b) + bench("$$$ !=/2", do: @big_string_a != @big_string_b) end diff --git a/bench/witchcraft/setoid/float_bench.exs b/bench/witchcraft/setoid/float_bench.exs index 81d0747..f481df5 100644 --- a/bench/witchcraft/setoid/float_bench.exs +++ b/bench/witchcraft/setoid/float_bench.exs @@ -19,22 +19,22 @@ defmodule Witchcraft.Setoid.FloatBench do # Kernel # ########## - bench "Kernel.==/2", do: Kernel.==(@float_a, @float_b) - bench "Kernel.!=/2", do: Kernel.!=(@float_a, @float_b) + bench("Kernel.==/2", do: Kernel.==(@float_a, @float_b)) + bench("Kernel.!=/2", do: Kernel.!=(@float_a, @float_b)) ########## # Setoid # ########## - bench "equivalent?/2", do: equivalent?(@float_a, @float_b) - bench "nonequivalent?/2", do: nonequivalent?(@float_a, @float_b) + bench("equivalent?/2", do: equivalent?(@float_a, @float_b)) + bench("nonequivalent?/2", do: nonequivalent?(@float_a, @float_b)) # --------- # # Operators # # --------- # - bench "==/2", do: @float_a == @float_b - bench "!=/2", do: @float_a != @float_b + bench("==/2", do: @float_a == @float_b) + bench("!=/2", do: @float_a != @float_b) # ---------- # # Large Data # @@ -43,9 +43,9 @@ defmodule Witchcraft.Setoid.FloatBench do @big_float_a 1_234_567.890 @big_float_b 9_876.543210 - bench "$$$ Kernel.==/2", do: Kernel.==(@big_float_a, @big_float_b) - bench "$$$ Kernel.!=/2", do: Kernel.!=(@big_float_a, @big_float_b) + bench("$$$ Kernel.==/2", do: Kernel.==(@big_float_a, @big_float_b)) + bench("$$$ Kernel.!=/2", do: Kernel.!=(@big_float_a, @big_float_b)) - bench "$$$ ==/2", do: @big_float_a == @big_float_b - bench "$$$ !=/2", do: @big_float_a != @big_float_b + bench("$$$ ==/2", do: @big_float_a == @big_float_b) + bench("$$$ !=/2", do: @big_float_a != @big_float_b) end diff --git a/bench/witchcraft/setoid/integer_bench.exs b/bench/witchcraft/setoid/integer_bench.exs index 08b7fae..d7f6990 100644 --- a/bench/witchcraft/setoid/integer_bench.exs +++ b/bench/witchcraft/setoid/integer_bench.exs @@ -19,22 +19,22 @@ defmodule Witchcraft.Setoid.IntegerBench do # Kernel # ########## - bench "Kernel.==/2", do: Kernel.==(@int_a, @int_b) - bench "Kernel.!=/2", do: Kernel.!=(@int_a, @int_b) + bench("Kernel.==/2", do: Kernel.==(@int_a, @int_b)) + bench("Kernel.!=/2", do: Kernel.!=(@int_a, @int_b)) ########## # Setoid # ########## - bench "equivalent?/2", do: equivalent?(@int_a, @int_b) - bench "nonequivalent?/2", do: nonequivalent?(@int_a, @int_b) + bench("equivalent?/2", do: equivalent?(@int_a, @int_b)) + bench("nonequivalent?/2", do: nonequivalent?(@int_a, @int_b)) # --------- # # Operators # # --------- # - bench "==/2", do: @int_a == @int_b - bench "!=/2", do: @int_a != @int_b + bench("==/2", do: @int_a == @int_b) + bench("!=/2", do: @int_a != @int_b) # ---------- # # Large Data # @@ -43,9 +43,9 @@ defmodule Witchcraft.Setoid.IntegerBench do @big_int_a 1_234_567_890 @big_int_b 9_876_543_210 - bench "$$$ Kernel.==/2", do: Kernel.==(@big_int_a, @big_int_b) - bench "$$$ Kernel.!=/2", do: Kernel.!=(@big_int_a, @big_int_b) + bench("$$$ Kernel.==/2", do: Kernel.==(@big_int_a, @big_int_b)) + bench("$$$ Kernel.!=/2", do: Kernel.!=(@big_int_a, @big_int_b)) - bench "$$$ ==/2", do: @big_int_a == @big_int_b - bench "$$$ !=/2", do: @big_int_a != @big_int_b + bench("$$$ ==/2", do: @big_int_a == @big_int_b) + bench("$$$ !=/2", do: @big_int_a != @big_int_b) end diff --git a/bench/witchcraft/setoid/list_bench.exs b/bench/witchcraft/setoid/list_bench.exs index ae95bf9..962185b 100644 --- a/bench/witchcraft/setoid/list_bench.exs +++ b/bench/witchcraft/setoid/list_bench.exs @@ -19,33 +19,33 @@ defmodule Witchcraft.Setoid.ListBench do # Kernel # ########## - bench "Kernel.==/2", do: Kernel.==(@list_a, @list_b) - bench "Kernel.!=/2", do: Kernel.!=(@list_a, @list_b) + bench("Kernel.==/2", do: Kernel.==(@list_a, @list_b)) + bench("Kernel.!=/2", do: Kernel.!=(@list_a, @list_b)) ########## # Setoid # ########## - bench "equivalent?/2", do: equivalent?(@list_a, @list_b) - bench "nonequivalent?/2", do: nonequivalent?(@list_a, @list_b) + bench("equivalent?/2", do: equivalent?(@list_a, @list_b)) + bench("nonequivalent?/2", do: nonequivalent?(@list_a, @list_b)) # --------- # # Operators # # --------- # - bench "==/2", do: @list_a == @list_b - bench "!=/2", do: @list_a != @list_b + bench("==/2", do: @list_a == @list_b) + bench("!=/2", do: @list_a != @list_b) # ---------- # # Large Data # # ---------- # - @big_list_a 0..100_000 |> Enum.to_list() |> Enum.shuffle() + @big_list_a 0..100_000 |> Enum.to_list() |> Enum.shuffle() @big_list_b 99..999_999 |> Enum.to_list() |> Enum.shuffle() - bench "$$$ Kernel.==/2", do: Kernel.==(@big_list_a, @big_list_b) - bench "$$$ Kernel.!=/2", do: Kernel.!=(@big_list_a, @big_list_b) + bench("$$$ Kernel.==/2", do: Kernel.==(@big_list_a, @big_list_b)) + bench("$$$ Kernel.!=/2", do: Kernel.!=(@big_list_a, @big_list_b)) - bench "$$$ ==/2", do: @big_list_a == @big_list_b - bench "$$$ !=/2", do: @big_list_a != @big_list_b + bench("$$$ ==/2", do: @big_list_a == @big_list_b) + bench("$$$ !=/2", do: @big_list_a != @big_list_b) end diff --git a/bench/witchcraft/setoid/map_bench.exs b/bench/witchcraft/setoid/map_bench.exs index f633206..a8b948f 100644 --- a/bench/witchcraft/setoid/map_bench.exs +++ b/bench/witchcraft/setoid/map_bench.exs @@ -22,36 +22,36 @@ defmodule Witchcraft.Setoid.MapBench do # Kernel # ########## - bench "Kernel.==/2", do: Kernel.==(@map_a, @map_b) - bench "Kernel.!=/2", do: Kernel.!=(@map_a, @map_b) + bench("Kernel.==/2", do: Kernel.==(@map_a, @map_b)) + bench("Kernel.!=/2", do: Kernel.!=(@map_a, @map_b)) ########## # Setoid # ########## - bench "equivalent?/2", do: equivalent?(@map_a, @map_b) - bench "nonequivalent?/2", do: nonequivalent?(@map_a, @map_b) + bench("equivalent?/2", do: equivalent?(@map_a, @map_b)) + bench("nonequivalent?/2", do: nonequivalent?(@map_a, @map_b)) # --------- # # Operators # # --------- # - bench "==/2", do: @map_a == @map_b - bench "!=/2", do: @map_a != @map_b + bench("==/2", do: @map_a == @map_b) + bench("!=/2", do: @map_a != @map_b) # ---------- # # Large Data # # ---------- # - @big_list_a 0..100_000 |> Enum.to_list() |> Enum.shuffle() + @big_list_a 0..100_000 |> Enum.to_list() |> Enum.shuffle() @big_list_b 99..999_999 |> Enum.to_list() |> Enum.shuffle() @big_map_a @big_list_a |> Enum.zip(@list_b) |> Enum.into(%{}) @big_map_b @big_list_b |> Enum.zip(@list_a) |> Enum.into(%{}) - bench "$$$ Kernel.==/2", do: Kernel.==(@big_map_a, @big_map_b) - bench "$$$ Kernel.!=/2", do: Kernel.!=(@big_map_a, @big_map_b) + bench("$$$ Kernel.==/2", do: Kernel.==(@big_map_a, @big_map_b)) + bench("$$$ Kernel.!=/2", do: Kernel.!=(@big_map_a, @big_map_b)) - bench "$$$ ==/2", do: @big_map_a == @big_map_b - bench "$$$ !=/2", do: @big_map_a != @big_map_b + bench("$$$ ==/2", do: @big_map_a == @big_map_b) + bench("$$$ !=/2", do: @big_map_a != @big_map_b) end diff --git a/bench/witchcraft/setoid/map_set_bench.exs b/bench/witchcraft/setoid/map_set_bench.exs index a206850..17968d9 100644 --- a/bench/witchcraft/setoid/map_set_bench.exs +++ b/bench/witchcraft/setoid/map_set_bench.exs @@ -19,22 +19,22 @@ defmodule Witchcraft.Setoid.MapSetBench do # Kernel # ########## - bench "Kernel.==/2", do: Kernel.==(@map_set_a, @map_set_b) - bench "Kernel.!=/2", do: Kernel.!=(@map_set_a, @map_set_b) + bench("Kernel.==/2", do: Kernel.==(@map_set_a, @map_set_b)) + bench("Kernel.!=/2", do: Kernel.!=(@map_set_a, @map_set_b)) ########## # Setoid # ########## - bench "equivalent?/2", do: equivalent?(@map_set_a, @map_set_b) - bench "nonequivalent?/2", do: nonequivalent?(@map_set_a, @map_set_b) + bench("equivalent?/2", do: equivalent?(@map_set_a, @map_set_b)) + bench("nonequivalent?/2", do: nonequivalent?(@map_set_a, @map_set_b)) # --------- # # Operators # # --------- # - bench "==/2", do: @map_set_a == @map_set_b - bench "!=/2", do: @map_set_a != @map_set_b + bench("==/2", do: @map_set_a == @map_set_b) + bench("!=/2", do: @map_set_a != @map_set_b) # ---------- # # Large Data # @@ -43,9 +43,9 @@ defmodule Witchcraft.Setoid.MapSetBench do @big_map_set_a MapSet.new(0..1_000) @big_map_set_b MapSet.new(99..999) - bench "$$$ Kernel.==/2", do: Kernel.==(@big_map_set_a, @big_map_set_b) - bench "$$$ Kernel.!=/2", do: Kernel.!=(@big_map_set_a, @big_map_set_b) + bench("$$$ Kernel.==/2", do: Kernel.==(@big_map_set_a, @big_map_set_b)) + bench("$$$ Kernel.!=/2", do: Kernel.!=(@big_map_set_a, @big_map_set_b)) - bench "$$$ ==/2", do: @big_map_set_a == @big_map_set_b - bench "$$$ !=/2", do: @big_map_set_a != @big_map_set_b + bench("$$$ ==/2", do: @big_map_set_a == @big_map_set_b) + bench("$$$ !=/2", do: @big_map_set_a != @big_map_set_b) end diff --git a/bench/witchcraft/setoid/tuple_bench.exs b/bench/witchcraft/setoid/tuple_bench.exs index 07310b5..2355d91 100644 --- a/bench/witchcraft/setoid/tuple_bench.exs +++ b/bench/witchcraft/setoid/tuple_bench.exs @@ -19,33 +19,33 @@ defmodule Witchcraft.Setoid.TupleBench do # Kernel # ########## - bench "Kernel.==/2", do: Kernel.==(@tuple_a, @tuple_b) - bench "Kernel.!=/2", do: Kernel.!=(@tuple_a, @tuple_b) + bench("Kernel.==/2", do: Kernel.==(@tuple_a, @tuple_b)) + bench("Kernel.!=/2", do: Kernel.!=(@tuple_a, @tuple_b)) ########## # Setoid # ########## - bench "equivalent?/2", do: equivalent?(@tuple_a, @tuple_b) - bench "nonequivalent?/2", do: nonequivalent?(@tuple_a, @tuple_b) + bench("equivalent?/2", do: equivalent?(@tuple_a, @tuple_b)) + bench("nonequivalent?/2", do: nonequivalent?(@tuple_a, @tuple_b)) # --------- # # Operators # # --------- # - bench "==/2", do: @tuple_a == @tuple_b - bench "!=/2", do: @tuple_a != @tuple_b + bench("==/2", do: @tuple_a == @tuple_b) + bench("!=/2", do: @tuple_a != @tuple_b) # ---------- # # Large Data # # ---------- # - @big_tuple_a 0..100_000 |> Enum.to_list() |> Enum.shuffle() |> List.to_tuple() + @big_tuple_a 0..100_000 |> Enum.to_list() |> Enum.shuffle() |> List.to_tuple() @big_tuple_b 99..999_999 |> Enum.to_list() |> Enum.shuffle() |> List.to_tuple() - bench "$$$ Kernel.==/2", do: Kernel.==(@big_tuple_a, @big_tuple_b) - bench "$$$ Kernel.!=/2", do: Kernel.!=(@big_tuple_a, @big_tuple_b) + bench("$$$ Kernel.==/2", do: Kernel.==(@big_tuple_a, @big_tuple_b)) + bench("$$$ Kernel.!=/2", do: Kernel.!=(@big_tuple_a, @big_tuple_b)) - bench "$$$ ==/2", do: @big_tuple_a == @big_tuple_b - bench "$$$ !=/2", do: @big_tuple_a != @big_tuple_b + bench("$$$ ==/2", do: @big_tuple_a == @big_tuple_b) + bench("$$$ !=/2", do: @big_tuple_a != @big_tuple_b) end diff --git a/bench/witchcraft/traversable/list_bench.exs b/bench/witchcraft/traversable/list_bench.exs index 645db26..b22f7b3 100644 --- a/bench/witchcraft/traversable/list_bench.exs +++ b/bench/witchcraft/traversable/list_bench.exs @@ -21,10 +21,10 @@ defmodule Witchcraft.Traversable.ListBench do # Traversable # ############### - bench "traverse/2", do: @list |> traverse(fn x -> {x, x + 1} end) - bench "through/2", do: fn x -> {x, x + 1} end |> through(@list) + bench("traverse/2", do: @list |> traverse(fn x -> {x, x + 1} end)) + bench("through/2", do: fn x -> {x, x + 1} end |> through(@list)) - bench "sequence/1", do: sequence(@nested_list) + bench("sequence/1", do: sequence(@nested_list)) # ---------- # # Large Data # @@ -35,9 +35,8 @@ defmodule Witchcraft.Traversable.ListBench do @big_nested_list replace(@med_list, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}) - bench "$$$ traverse/2", do: @big_list |> traverse(fn x -> {x, x + 1} end) - bench "$$$ through/2", do: fn x -> {x, x + 1} end |> through(@big_list) - - bench "$$$ sequence/1", do: sequence(@big_nested_list) + bench("$$$ traverse/2", do: @big_list |> traverse(fn x -> {x, x + 1} end)) + bench("$$$ through/2", do: fn x -> {x, x + 1} end |> through(@big_list)) + bench("$$$ sequence/1", do: sequence(@big_nested_list)) end diff --git a/bench/witchcraft/traversable/tuple_bench.exs b/bench/witchcraft/traversable/tuple_bench.exs index 521e578..76bc71e 100644 --- a/bench/witchcraft/traversable/tuple_bench.exs +++ b/bench/witchcraft/traversable/tuple_bench.exs @@ -21,10 +21,10 @@ defmodule Witchcraft.Traversable.TupleBench do # Traversable # ############### - bench "traverse/2", do: @tuple |> traverse(fn x -> [x, x + 1] end) - bench "through/2", do: fn x -> [x, x + 1] end |> through(@tuple) + bench("traverse/2", do: @tuple |> traverse(fn x -> [x, x + 1] end)) + bench("through/2", do: fn x -> [x, x + 1] end |> through(@tuple)) - bench "sequence/1", do: sequence(@nested_tuple) + bench("sequence/1", do: sequence(@nested_tuple)) # ---------- # # Large Data # @@ -35,9 +35,8 @@ defmodule Witchcraft.Traversable.TupleBench do @big_nested_tuple replace(@med_tuple, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) - bench "$$$ traverse/2", do: @big_tuple |> traverse(fn x -> [x, x + 1] end) - bench "$$$ through/2", do: fn x -> [x, x + 1] end |> through(@big_tuple) - - bench "$$$ sequence/1", do: sequence(@big_nested_tuple) + bench("$$$ traverse/2", do: @big_tuple |> traverse(fn x -> [x, x + 1] end)) + bench("$$$ through/2", do: fn x -> [x, x + 1] end |> through(@big_tuple)) + bench("$$$ sequence/1", do: sequence(@big_nested_tuple)) end diff --git a/bench/witchcraft/unit_bench.exs b/bench/witchcraft/unit_bench.exs index b79d8aa..b21975f 100644 --- a/bench/witchcraft/unit_bench.exs +++ b/bench/witchcraft/unit_bench.exs @@ -4,7 +4,7 @@ defmodule Witchcraft.UnitBench do use Benchfella import Witchcraft.Unit - bench "new/0", do: new() - bench "struct/1", do: struct(Witchcraft.Unit) - bench "%Unit{}", do: %Witchcraft.Unit{} + bench("new/0", do: new()) + bench("struct/1", do: struct(Witchcraft.Unit)) + bench("%Unit{}", do: %Witchcraft.Unit{}) end From e716d133fe68111bd5a8408b7fe9c46ae8f533d8 Mon Sep 17 00:00:00 2001 From: Quinn Wilton Date: Thu, 3 Feb 2022 12:35:17 -0800 Subject: [PATCH 4/4] Un-import Kernel.then/2 from benchmarks that require Apply.then/2 --- bench/witchcraft/apply/function_bench.exs | 2 ++ bench/witchcraft/apply/list_bench.exs | 2 ++ bench/witchcraft/apply/tuple_bench.exs | 2 ++ 3 files changed, 6 insertions(+) diff --git a/bench/witchcraft/apply/function_bench.exs b/bench/witchcraft/apply/function_bench.exs index 84cbdbf..648be92 100644 --- a/bench/witchcraft/apply/function_bench.exs +++ b/bench/witchcraft/apply/function_bench.exs @@ -1,6 +1,8 @@ defmodule Witchcraft.Apply.FunBench do @moduledoc false + import Kernel, except: [then: 2] + use Benchfella use Witchcraft.Apply diff --git a/bench/witchcraft/apply/list_bench.exs b/bench/witchcraft/apply/list_bench.exs index 6d9b16e..40bc2ad 100644 --- a/bench/witchcraft/apply/list_bench.exs +++ b/bench/witchcraft/apply/list_bench.exs @@ -1,6 +1,8 @@ defmodule Witchcraft.Apply.ListBench do @moduledoc false + import Kernel, except: [then: 2] + use Benchfella use Witchcraft.Apply diff --git a/bench/witchcraft/apply/tuple_bench.exs b/bench/witchcraft/apply/tuple_bench.exs index dace9d0..13a60c6 100644 --- a/bench/witchcraft/apply/tuple_bench.exs +++ b/bench/witchcraft/apply/tuple_bench.exs @@ -1,6 +1,8 @@ defmodule Witchcraft.Apply.TupleBench do @moduledoc false + import Kernel, except: [then: 2] + use Benchfella use Witchcraft.Apply