From ec463a0f55fc6bec9cc41f01753f9aa0da8167b7 Mon Sep 17 00:00:00 2001 From: Daniel Jaouen Date: Mon, 15 Apr 2024 01:19:48 -0400 Subject: [PATCH] Remove ParallelStream --- README.md | 6 ------ lib/dynamic_programming_in_elixir.ex | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/README.md b/README.md index c1af58a..be76678 100644 --- a/README.md +++ b/README.md @@ -16,12 +16,6 @@ $ mix test ## LFE version [Here.](https://github.com/danieljaouen/dynamic-programming-in-lfe) -Note: The Elixir version is currently more performant due to parallel processing. - -Edit: Maybe not. Looks like ParalleStream adds a significant overhead. Check -your results with `:timer.tc(fn -> lowest_cose_path(...) end)` first and -perhaps modify your version of the code to not use ParallelStream. - ## License Apache License, Version 2.0 diff --git a/lib/dynamic_programming_in_elixir.ex b/lib/dynamic_programming_in_elixir.ex index 6e2d771..db1286a 100644 --- a/lib/dynamic_programming_in_elixir.ex +++ b/lib/dynamic_programming_in_elixir.ex @@ -55,7 +55,7 @@ defmodule DynamicProgrammingInElixir do {:error, "Cannot reach source from current path"} else in_edges - |> ParallelStream.map(fn edge -> calculate_current_path(g, source, edge) end) + |> Enum.map(fn edge -> calculate_current_path(g, source, edge) end) |> Enum.filter(fn x -> elem(x, 0) == :ok end) |> Enum.to_list() |> my_min()