There is an updated version that improved the performance of the Map version:
Fib.ets/2
: 23.314 msFib.mem/2
: 23.493 msFib.lco/1
: 26.574 ms
Essentially adding a value at a time with Map.put/3
was too slow. It was faster to collect all the new values as key value pairs in a list and add them all at once with :maps.merge/2
.
new_mem =
kvs
|> :maps.from_list(kvs)
|> :maps.merge(mem)