bencheeorg / benchee

Easy and extensible benchmarking in Elixir providing you with lots of statistics!
MIT License
1.41k stars 66 forks source link

(Protocol.UndefinedError) protocol List.Chars not implemented for {:error, :bad_name} #384

Closed Munksgaard closed 10 months ago

Munksgaard commented 1 year ago

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.

PragTob commented 10 months ago

EEEEEEK

thanks for the report :green_heart: Also, sorry for the long down time. Lots of going on.

Me and escripts :joy: Let me see if I can reproduce and figure this one out

PragTob commented 10 months ago

Reproduced!

PragTob commented 10 months ago

Alright, that's just a procol consolidation check that may or may not still be relevant that fails on looking up the elixir executable I can probably fix this easily or at least circumvent it

Munksgaard commented 10 months ago

thanks for the report 💚 Also, sorry for the long down time. Lots of going on.

No worries! I appreciate the work you're doing :heart:

PragTob commented 10 months ago

And fixed on main via #395 ! Thanks again for the report!