Report of 300.000 lines in 0.4 seconds!
Created with Elixir.
Made with ❤️
- Generate reports of 300,000 different food dishes
- Use of parallel processes to generate the report in up to 0.4 seconds
- Single process option (for comparisons) of up to 1.1 seconds
- Elixir
- Erlang
SSH URLs provide access to a Git repository via SSH, a secure protocol. If you have an SSH key registered in your GitHub account, clone the project using this command:
git clone [email protected]:LuizFerK/Parallelixir.git
In case you don't have an SSH key on your GitHub account, you can clone the project using the HTTPS URL, run this command:
git clone https://github.com/LuizFerK/Parallelixir.git
Both of these commands will generate a folder called Parallelixir, with all the project
- Run
mix deps.get
to install the dependencies - This project does not have a server, in this case, the mode of use is through IEx (Elixir's interactive shell), which can be accessed using the command
iex -S mix
in the project folder - Within IEx, you have two usage options: standard execution (which will run 300 thousand lines in just one process) and parallel execution (which will run 3 files of 100.000 lines simultaneously). To use the standard mode, run the following command:
ReportsGenerator.build("report_complete.csv")
- If you want to use the parallel mode, run the following command:
ReportsGenerator.build_from_many(["report_1.csv", "report_2.csv", "report_3.csv"])
- In both modes, you will have the same result, however, parallel execution will be faster
- The result will be a map with the following information:
foods
(representing the total times that every food appears in the files) andusers
(representing the total times that every user appears in the files), as you can see below:
{:ok,
%{
"foods" => %{
"açaí" => 37742,
"churrasco" => 37650,
"esfirra" => 37462,
"hambúrguer" => 37577,
"pastel" => 37392,
"pizza" => 37365,
"prato_feito" => 37519,
"sushi" => 37293
},
"users" => %{
"1" => 278849,
"10" => 268317,
"11" => 268877,
"12" => 276306,
"13" => 282953,
"14" => 277084,
"15" => 280105,
"16" => 271831,
"17" => 272883,
"18" => 271421,
"19" => 277720,
"2" => 271031,
"20" => 273446,
"21" => 275026,
"22" => 278025,
"23" => 276523,
"24" => 274481,
"25" => 274512,
"26" => 274199,
"27" => 278001,
"28" => 274256,
"29" => 273030,
"3" => 272250,
"30" => 275978,
"4" => 277054,
"5" => 270926,
"6" => 272053,
"7" => 273112,
"8" => 275161,
"9" => 274003
}
}}
- Tasks
Find a bug or error on the project? Please, feel free to send me the issue on the Parallelixir issues area, with a title and a description of your found!
If you know the origin of the error and know how to resolve it, please, send me a pull request, I will love to review it!
Released in 2021.
This project is under the MIT license.
< keep coding /> 🚀 ❤️