Skip to content

Instantly share code, notes, and snippets.

@palladin
Created July 27, 2014 15:05
Show Gist options
  • Save palladin/c34a3a761f755b57244c to your computer and use it in GitHub Desktop.
Save palladin/c34a3a761f755b57244c to your computer and use it in GitHub Desktop.
ParStream.sortBy performance test
#time
#r "bin/Release/Streams.Core.dll"
open Nessos.Streams.Core
let rnd = new System.Random()
let data = [|1..10000000|] |> Array.map (fun _ -> int64 <| rnd.Next(1000000))
#r "../../packages/FSharp.Collections.ParallelSeq.1.0/lib/net40/FSharp.Collections.ParallelSeq.dll"
open FSharp.Collections.ParallelSeq
// Real: 00:00:03.095, CPU: 00:00:14.679, GC gen0: 3, gen1: 2, gen2: 2
data
|> PSeq.map (fun x -> x + 1L)
|> PSeq.sortBy id
|> PSeq.toArray
// Real: 00:00:00.917, CPU: 00:00:04.321, GC gen0: 1, gen1: 0, gen2: 0
data
|> ParStream.ofArray
|> ParStream.map (fun x -> x + 1L)
|> ParStream.sortBy id
@exercitusvir
Copy link

Ah, I see. Thanks for the detailed explanations!

@exercitusvir
Copy link

Btw, it might be helpful to add that explanation to the readme. First time I discovered your Streams API and read "inspired by Java 8 Streams" I didn't understand what makes Java 8 Streams special since it I thought that Java 8 Streams were just the Java version of Seq/IEnumerable+LINQ.

@palladin
Copy link
Author

Great suggestion, thnx for the feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment