Elixir File.stream! lines vs chunks
lines = File.stream!("file_path") | |
chunks = File.stream!("file_path",[],2_048) | |
hash_fun = fn enum -> | |
enum | |
|> Enum.reduce(:crypto.hash_init(:sha),&(:crypto.hash_update(&2, &1))) | |
|> :crypto.hash_final() | |
|> Base.encode16() | |
end | |
Benchee.run(%{ | |
"lines" => fn -> | |
lines | |
|> hash_fun.() | |
end, | |
"chunks" => fn -> | |
chunks | |
|> hash_fun.() | |
end | |
}, | |
time: 10, | |
memory_time: 2 | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment