Created
April 9, 2019 11:08
-
-
Save alvises/54451c50ac0b9bafe0c932e4b2240b32 to your computer and use it in GitHub Desktop.
Elixir File.stream! lines vs chunks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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