Using F # async for purely CPU-bound tasks only works if tasks perform a more complex operation. If you are trying to parallelize code that does something very simple, it is best to use PLINQ (and a parallel task library), which are more optimized for these problems.
However, even then, obtaining acceleration in a trivial case, as in your case, is difficult. If you want to experiment a little more with this, you can try the following:
// Turn on timing in F
Note: using Array.map itself Array.map much faster than using sequence expressions and then converting the result to an array. If you want to use more complex operations than matching, then F # PowerPack contains a PSeq module with functions similar to those in Seq or List :
#r @"FSharp.PowerPack.Parallel.Seq.dll" data |> PSeq.map (fun a -> ...) |> PSeq.filter (fun a -> ...) |> PSeq.sort |> Array.ofSeq
If you want to know more about this, I recently published a series of a parallel programming blog in F # .
Tomas petricek
source share