Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. lines = File.stream!("file_path")
  2. chunks = File.stream!("file_path",[],2_048)
  3.  
  4. hash_fun = fn enum ->
  5. enum
  6. |> Enum.reduce(:crypto.hash_init(:sha),&(:crypto.hash_update(&2, &1)))
  7. |> :crypto.hash_final()
  8. |> Base.encode16()
  9. end
  10.  
  11. Benchee.run(%{
  12. "lines" => fn ->
  13. lines
  14. |> hash_fun.()
  15. end,
  16. "chunks" => fn ->
  17. chunks
  18. |> hash_fun.()
  19. end
  20. },
  21. time: 10,
  22. memory_time: 2
  23. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement