Created
January 13, 2019 20:47
-
-
Save alvises/3b16c146f60dbd766d1af9cf18c73319 to your computer and use it in GitHub Desktop.
Benchee benchmark of csv processing
This file contains hidden or 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
lazy_csv_fn = fn -> | |
File.stream!("large.csv") | |
|> Stream.map(&String.trim(&1)) | |
|> Stream.map(&String.split(&1, ",")) | |
|> Stream.filter(fn | |
["Timestamp" | _] -> false | |
[_, "NaN" | _] -> false | |
[timestamp | _] -> | |
true | |
end) |> Enum.find(fn | |
[timestamp | _] -> | |
ts = String.to_integer(timestamp) | |
dt = DateTime.from_unix!(ts) | |
dt.year == 2015 | |
end) | |
end | |
Benchee.run(%{ | |
"lazy_csv" => lazy_csv_fn | |
}, time: 10, memory_time: 2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment