Skip to content

Instantly share code, notes, and snippets.

@madlep
Last active September 16, 2025 12:14
Show Gist options
  • Select an option

  • Save madlep/e47e183b535e9213e53ec99eba6c9dcd to your computer and use it in GitHub Desktop.

Select an option

Save madlep/e47e183b535e9213e53ec99eba6c9dcd to your computer and use it in GitHub Desktop.
kino_benchee faceted charts on benchee benchmark input_name

facet-charts-by-input_name

Mix.install([
  {:benchee,
   git: "https://github.com/madlep/benchee.git",
   branch: "include-input_name-in-table",
   override: true},
  {:kino_benchee,
   git: "https://github.com/madlep/kino_benchee.git", branch: "facet-charts-by-input_name"}
])

Section

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: 1,
  memory_time: 1,
  reduction_time: 1
)
|> Kino.DataTable.new()
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: 1,
  memory_time: 1,
  reduction_time: 1
)
list = Enum.to_list(1..10_000)
map_fun = fn i -> [i, i * i] end

Benchee.run(
  %{
    "flat_map" => fn input -> Enum.flat_map(input, map_fun) end,
    "map.flatten" => fn input -> input |> Enum.map(map_fun) |> List.flatten() end
  },
  inputs: %{
    "Small" => Enum.to_list(1..1_000),
    "Medium" => Enum.to_list(1..10_000),
    "Bigger" => Enum.to_list(1..100_000)
  },
  time: 1,
  memory_time: 1,
  reduction_time: 1
)
list = Enum.to_list(1..10_000)
map_fun = fn i -> [i, i * i] end

Benchee.run(
  %{
    "flat_map" => fn input -> Enum.flat_map(input, map_fun) end,
    "map.flatten" => fn input -> input |> Enum.map(map_fun) |> List.flatten() end
  },
  inputs: %{
    "Small" => Enum.to_list(1..1_000),
    "Medium" => Enum.to_list(1..10_000),
    "Bigger" => Enum.to_list(1..100_000)
  },
  time: 1,
  memory_time: 1,
  reduction_time: 1
)
|> Kino.DataTable.new()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment