Exercise

Word frequency with doFuture and benchmarking

Now your job is to create a function freq_doFut() that accomplishes the same task as freq_doPar() but with the doFuture backend. Note that when using doFuture, arguments .packages and .export in foreach() are not necessary, as the package deals with the exports automatically.

You will then benchmark these two functions, together with the sequential freq_seq(). All the functions from the last exercise are available in your workspace. In addition, the packages doFuture and microbenchmark are also preloaded. To keep the computation time low, the global chars vector is set to the first six letters of the alphabet only.

Instructions 1/2

undefined XP
    1
    2
  • Define freq_doFut() with the same arguments as freq_doPar().
  • Register doFuture using registerDoFuture() and set its plan() to cluster, passing cores as the workers argument.