Closed
Description
When using the initial example from the README to the main/1
of an escript, building with mix escript.build
and running the resulting executable, I get the following error:
** (Protocol.UndefinedError) protocol List.Chars not implemented for {:error, :bad_name} of type Tuple. This protocol is implemented for the following type(s): Atom, BitString, Float, Integer, List
(elixir 1.14.3) lib/list/chars.ex:1: List.Chars.impl_for!/1
(elixir 1.14.3) lib/list/chars.ex:17: List.Chars.to_charlist/1
(elixir 1.14.3) lib/protocol.ex:493: anonymous fn/4 in Protocol.extract_matching_by_attribute/3
(elixir 1.14.3) lib/enum.ex:2468: Enum."-reduce/3-lists^foldl/2-0-"/3
(elixir 1.14.3) lib/protocol.ex:492: Protocol.extract_matching_by_attribute/3
(benchee 1.1.0) lib/benchee/system.ex:186: Benchee.System.all_protocols_consolidated?/0
(benchee 1.1.0) lib/benchee/system.ex:173: Benchee.System.warn_about_performance_degrading_settings/0
(benchee 1.1.0) lib/benchee/system.ex:27: Benchee.System.system/1
Here's the module I've defined:
defmodule Foo do
def main(args \\ []) do
list = Enum.to_list(1..10_000)
map_fun = fn i -> [i, i * i] end
Benchee.run(
%{
"flat_map" => fn -> Enum.flat_map(list, map_fun) end,
"map.flatten" => fn -> list |> Enum.map(map_fun) |> List.flatten() end
},
time: 10,
memory_time: 2
)
end
end
I am using elixir 1.14.3 and OPT 25.