diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index a42d01d..2228168 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,9 @@ +### 2.0.17 - 21.11.2017 +* Improve performance of internal Async.chooseTasks function which improves performance of AsyncSeq.bufferByCountAndTime, etc (https://github.com/fsprojects/FSharp.Control.AsyncSeq/pull/73) + +### 2.0.16 - 29.09.2017 +* Fix previous package deployment + ### 2.0.15 - 27.09.2017 * NEW: AsyncSeq.bufferByTime diff --git a/src/FSharp.Control.AsyncSeq.Profile7/AssemblyInfo.fs b/src/FSharp.Control.AsyncSeq.Profile7/AssemblyInfo.fs index 6cae419..436fe20 100644 --- a/src/FSharp.Control.AsyncSeq.Profile7/AssemblyInfo.fs +++ b/src/FSharp.Control.AsyncSeq.Profile7/AssemblyInfo.fs @@ -4,10 +4,10 @@ open System.Reflection [] [] [] -[] -[] +[] +[] do () module internal AssemblyVersionInformation = - let [] Version = "2.0.14" - let [] InformationalVersion = "2.0.14" + let [] Version = "2.0.17" + let [] InformationalVersion = "2.0.17" diff --git a/src/FSharp.Control.AsyncSeq/AssemblyInfo.fs b/src/FSharp.Control.AsyncSeq/AssemblyInfo.fs index 5aac1c1..7ec171e 100644 --- a/src/FSharp.Control.AsyncSeq/AssemblyInfo.fs +++ b/src/FSharp.Control.AsyncSeq/AssemblyInfo.fs @@ -4,10 +4,10 @@ open System.Reflection [] [] [] -[] -[] +[] +[] do () module internal AssemblyVersionInformation = - let [] Version = "2.0.14" - let [] InformationalVersion = "2.0.14" + let [] Version = "2.0.17" + let [] InformationalVersion = "2.0.17" diff --git a/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqPerf.fsx b/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqPerf.fsx index f7e4817..8a579e0 100644 --- a/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqPerf.fsx +++ b/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqPerf.fsx @@ -118,6 +118,39 @@ let collect n = //run replicate //run bind //run bindUnfold -run collect +//run collect +let Y = Choice1Of2 +let S = Choice2Of2 + +let timeMs = 500 +let inp0 = [ ] +let exp0 = [ ] + +let inp1 = [ Y 1 ; Y 2 ; S timeMs ; Y 3 ; Y 4 ; S timeMs ; Y 5 ; Y 6 ] +let exp1 = [ [1;2] ; [3;4] ; [5;6] ] + +// let inp2 : Choice list = [ S 500 ] +// let exp2 : int list list = [ [] ; [] ; [] ; [] ] + +let toSeq (xs:Choice list) = asyncSeq { + for x in xs do + match x with + | Choice1Of2 v -> yield v + | Choice2Of2 s -> do! Async.Sleep s } + +for (inp,exp) in [ (inp0,exp0) ; (inp1,exp1) ] do + + let actual = + toSeq inp + |> AsyncSeq.bufferByTime (timeMs - 5) + |> AsyncSeq.map List.ofArray + |> AsyncSeq.toList + + printfn "actual=%A expected=%A" actual exp + + //let ls = toSeq inp |> AsyncSeq.toList + //let actualLs = actual |> List.concat + + \ No newline at end of file diff --git a/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs b/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs index cc8766c..d888431 100644 --- a/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs +++ b/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs @@ -448,27 +448,91 @@ let ``AsyncSeq.bufferByTimeAndCount empty``() = [] let ``AsyncSeq.bufferByTime`` () = - - let s = asyncSeq { - yield 1 - yield 2 - do! Async.Sleep 100 - yield 3 - yield 4 - do! Async.Sleep 100 - yield 5 - yield 6 - } - let actual = - s - |> AsyncSeq.bufferByTime 100 - |> AsyncSeq.map (List.ofArray) - |> AsyncSeq.toList + let Y = Choice1Of2 + let S = Choice2Of2 - let expected = [ [1;2] ; [3;4] ; [5;6] ] + let timeMs = 500 - Assert.True ((actual = expected)) + let inp0 = [ ] + let exp0 = [ ] + + let inp1 = [ Y 1 ; Y 2 ; S timeMs ; Y 3 ; Y 4 ; S timeMs ; Y 5 ; Y 6 ] + let exp1 = [ [1;2] ; [3;4] ; [5;6] ] + +// let inp2 : Choice list = [ S 500 ] +// let exp2 : int list list = [ [] ; [] ; [] ; [] ] + + let toSeq (xs:Choice list) = asyncSeq { + for x in xs do + match x with + | Choice1Of2 v -> yield v + | Choice2Of2 s -> do! Async.Sleep s } + + for (inp,exp) in [ (inp0,exp0) ; (inp1,exp1) ] do + + let actual = + toSeq inp + |> AsyncSeq.bufferByTime (timeMs - 5) + |> AsyncSeq.map List.ofArray + |> AsyncSeq.toList + + //let ls = toSeq inp |> AsyncSeq.toList + //let actualLs = actual |> List.concat + + Assert.True ((actual = exp)) + +// WARNING: Too timing sensitive +//let rec prependToAll (a:'a) (ls:'a list) : 'a list = +// match ls with +// | [] -> [] +// | hd::tl -> a::hd::prependToAll a tl +// +//let rec intersperse (a:'a) (ls:'a list) : 'a list = +// match ls with +// | [] -> [] +// | hd::tl -> hd::prependToAll a tl +// +//let intercalate (l:'a list) (xs:'a list list) : 'a list = +// intersperse l xs |> List.concat +// +//let batch (size:int) (ls:'a list) : 'a list list = +// let rec go batch ls = +// match ls with +// | [] -> [List.rev batch] +// | _ when List.length batch = size -> (List.rev batch)::go [] ls +// | hd::tl -> go (hd::batch) tl +// go [] ls +// +//[] +//let ``AsyncSeq.bufferByTime2`` () = +// +// let Y = Choice1Of2 +// let S = Choice2Of2 +// let sleepMs = 100 +// +// let toSeq (xs:Choice list) = asyncSeq { +// for x in xs do +// match x with +// | Choice1Of2 v -> yield v +// | Choice2Of2 s -> do! Async.Sleep s } +// +// for (size,batchSize) in [ (0,0) ; (10,2) ; (100,2) ] do +// +// let expected = +// List.init size id +// |> batch batchSize +// +// let actual = +// expected +// |> List.map (List.map Y) +// |> intercalate [S sleepMs] +// |> toSeq +// |> AsyncSeq.bufferByTime sleepMs +// |> AsyncSeq.map List.ofArray +// |> AsyncSeq.toList +// +// Assert.True ((actual = expected)) [] let ``AsyncSeq.bufferByCountAndTime should not block`` () =