Count the frequency of letters in texts using parallel computation.
Parallelism is about doing things in parallel that can also be done sequentially. A common example is counting the frequency of letters. Create a function that returns the total frequency of each letter in a list of texts and that employs parallelism.
If you are solving this exercise locally, there is an included parallel_letter_frequency_benchmark_test.rb
file which will compare your parallel solution to a sequential one.
You can run it via ruby parallel_letter_frequency_benchmark_test.rb
.
The output will show execution times of each implementation over a range of large text counts in a tabular format.
Feel free to change the test cases.
You may want to investigate what performance impact length of text vs number of texts has on the execution time for each implementation.
Note: For smaller sets of text, the sequential count may be faster due to processing overhead costs.
Sign up to Exercism to learn and master Ruby with 20 concepts, 120 exercises, and real human mentoring, all for free.
We explore the differences between concurrency and parallelism, looking at different approaches taken by languages such as JavaScript, Go, Elixir and Rust.