Skip to content

Instantly share code, notes, and snippets.

@palladin
Last active September 25, 2021 17:52
Show Gist options
  • Save palladin/c5fca07b74da782832cb to your computer and use it in GitHub Desktop.
Save palladin/c5fca07b74da782832cb to your computer and use it in GitHub Desktop.
Parallel Streams Test
#time
#r "bin/Release/Streams.Core.dll"
open Nessos.Streams.Core
let data = [|1..10000000|] |> Array.map int64
#r "../../packages/FSharp.Collections.ParallelSeq.1.0/lib/net40/FSharp.Collections.ParallelSeq.dll"
open FSharp.Collections.ParallelSeq
// Real: 00:00:00.055, CPU: 00:00:00.187, GC gen0: 0, gen1: 0, gen2: 0
data
|> ParStream.ofArray
|> ParStream.map (fun x -> x + 1L)
|> ParStream.map (fun x -> x + 1L)
|> ParStream.map (fun x -> x + 1L)
|> ParStream.map (fun x -> x + 1L)
|> ParStream.map (fun x -> x + 1L)
|> ParStream.map (fun x -> x + 1L)
|> ParStream.map (fun x -> x + 1L)
|> ParStream.map (fun x -> x + 1L)
|> ParStream.length
// Real: 00:00:00.306, CPU: 00:00:01.513, GC gen0: 0, gen1: 0, gen2: 0
data
|> PSeq.map (fun x -> x + 1L)
|> PSeq.map (fun x -> x + 1L)
|> PSeq.map (fun x -> x + 1L)
|> PSeq.map (fun x -> x + 1L)
|> PSeq.map (fun x -> x + 1L)
|> PSeq.map (fun x -> x + 1L)
|> PSeq.map (fun x -> x + 1L)
|> PSeq.map (fun x -> x + 1L)
|> PSeq.length
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment