Tracks
/
Ruby
Ruby
/
Exercises
/
Parallel Letter Frequency
Parallel Letter Frequency

Parallel Letter Frequency

Medium

Instructions

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.

Benchmarking

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.

Further Reading

Edit via GitHub The link opens in a new window or tab
Ruby Exercism

Ready to start Parallel Letter Frequency?

Sign up to Exercism to learn and master Ruby with 20 concepts, 119 exercises, and real human mentoring, all for free.

Deep Dive into Parallel Letter Frequency!

We explore the differences between concurrency and parallelism, looking at different approaches taken by languages such as JavaScript, Go, Elixir and Rust.