From 2f2749f2dfa27047e57f2d43150778061624510f Mon Sep 17 00:00:00 2001 From: Lev Gorodinski Date: Wed, 27 Sep 2017 14:27:22 -0400 Subject: [PATCH 1/5] Bump version to 2.0.15 --- src/FSharp.Control.AsyncSeq.Profile7/AssemblyInfo.fs | 8 ++++---- src/FSharp.Control.AsyncSeq/AssemblyInfo.fs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/FSharp.Control.AsyncSeq.Profile7/AssemblyInfo.fs b/src/FSharp.Control.AsyncSeq.Profile7/AssemblyInfo.fs index 6cae419..1f7ab9e 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.15" + let [] InformationalVersion = "2.0.15" diff --git a/src/FSharp.Control.AsyncSeq/AssemblyInfo.fs b/src/FSharp.Control.AsyncSeq/AssemblyInfo.fs index 5aac1c1..053a359 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.15" + let [] InformationalVersion = "2.0.15" From bd6c71bb01f095725d7a6c30be3d27007b71be2d Mon Sep 17 00:00:00 2001 From: Lev Gorodinski Date: Fri, 29 Sep 2017 16:09:18 -0400 Subject: [PATCH 2/5] update release notes --- RELEASE_NOTES.md | 3 + .../AsyncSeqPerf.fsx | 54 +++++++++- .../AsyncSeqTests.fs | 100 ++++++++++++++---- 3 files changed, 136 insertions(+), 21 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index a42d01d..7b8aafd 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,6 @@ +### 2.0.16 - 29.09.2017 +* Fix previous package deployment + ### 2.0.15 - 27.09.2017 * NEW: AsyncSeq.bufferByTime diff --git a/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqPerf.fsx b/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqPerf.fsx index f7e4817..4541b3e 100644 --- a/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqPerf.fsx +++ b/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqPerf.fsx @@ -118,6 +118,54 @@ let collect n = //run replicate //run bind //run bindUnfold -run collect - - +//run collect + +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 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) ; (30,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)) + printfn "actual=%A expected=%A" actual expected \ 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..37850ea 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 = 100 - Assert.True ((actual = expected)) + let inp0 = [ ] + let exp0 = [ ] + + let inp1 = [ Y 1 ; Y 2 ; S 100 ; Y 3 ; Y 4 ; S 100 ; 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 100 + |> 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`` () = From 34b5e7323326d71468ca4b2e45abf7f844e9d6fb Mon Sep 17 00:00:00 2001 From: Lev Gorodinski Date: Fri, 29 Sep 2017 16:34:50 -0400 Subject: [PATCH 3/5] fix bufferByTime test --- .../AssemblyInfo.fs | 8 +-- src/FSharp.Control.AsyncSeq/AssemblyInfo.fs | 8 +-- .../AsyncSeqPerf.fsx | 55 +++++++------------ .../AsyncSeqTests.fs | 10 ++-- 4 files changed, 33 insertions(+), 48 deletions(-) diff --git a/src/FSharp.Control.AsyncSeq.Profile7/AssemblyInfo.fs b/src/FSharp.Control.AsyncSeq.Profile7/AssemblyInfo.fs index 1f7ab9e..08e7776 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.15" - let [] InformationalVersion = "2.0.15" + let [] Version = "2.0.16" + let [] InformationalVersion = "2.0.16" diff --git a/src/FSharp.Control.AsyncSeq/AssemblyInfo.fs b/src/FSharp.Control.AsyncSeq/AssemblyInfo.fs index 053a359..efc382a 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.15" - let [] InformationalVersion = "2.0.15" + let [] Version = "2.0.16" + let [] InformationalVersion = "2.0.16" diff --git a/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqPerf.fsx b/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqPerf.fsx index 4541b3e..8a579e0 100644 --- a/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqPerf.fsx +++ b/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqPerf.fsx @@ -120,52 +120,37 @@ let collect n = //run bindUnfold //run collect -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 Y = Choice1Of2 +let S = Choice2Of2 + +let timeMs = 500 -let intercalate (l:'a list) (xs:'a list list) : 'a list = - intersperse l xs |> List.concat +let inp0 = [ ] +let exp0 = [ ] -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 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 Y = Choice1Of2 -let S = Choice2Of2 -let sleepMs = 100 +// 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 } + | Choice2Of2 s -> do! Async.Sleep s } -for (size,batchSize) in [ (0,0) ; (10,2) ; (30,2) ] do +for (inp,exp) in [ (inp0,exp0) ; (inp1,exp1) ] do - let expected = - List.init size id - |> batch batchSize - let actual = - expected - |> List.map (List.map Y) - |> intercalate [S sleepMs] - |> toSeq - |> AsyncSeq.bufferByTime sleepMs + 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 - //Assert.True ((actual = expected)) - printfn "actual=%A expected=%A" actual expected \ No newline at end of file + \ 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 37850ea..d888431 100644 --- a/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs +++ b/tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs @@ -452,12 +452,12 @@ let ``AsyncSeq.bufferByTime`` () = let Y = Choice1Of2 let S = Choice2Of2 - let timeMs = 100 + let timeMs = 500 let inp0 = [ ] let exp0 = [ ] - let inp1 = [ Y 1 ; Y 2 ; S 100 ; Y 3 ; Y 4 ; S 100 ; Y 5 ; Y 6 ] + 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 ] @@ -473,12 +473,12 @@ let ``AsyncSeq.bufferByTime`` () = let actual = toSeq inp - |> AsyncSeq.bufferByTime 100 + |> AsyncSeq.bufferByTime (timeMs - 5) |> AsyncSeq.map List.ofArray |> AsyncSeq.toList - let ls = toSeq inp |> AsyncSeq.toList - let actualLs = actual |> List.concat + //let ls = toSeq inp |> AsyncSeq.toList + //let actualLs = actual |> List.concat Assert.True ((actual = exp)) From 4181738c9b4e594e52a0f0102e0d5db9b49515d5 Mon Sep 17 00:00:00 2001 From: Lev Gorodinski Date: Tue, 21 Nov 2017 10:52:48 -0500 Subject: [PATCH 4/5] update release notes --- RELEASE_NOTES.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 7b8aafd..2228168 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,6 @@ +### 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 From 0bae599c6567f218087c0e52b773d7f2c33ab34a Mon Sep 17 00:00:00 2001 From: Lev Gorodinski Date: Tue, 21 Nov 2017 10:54:29 -0500 Subject: [PATCH 5/5] update assembly version --- src/FSharp.Control.AsyncSeq.Profile7/AssemblyInfo.fs | 8 ++++---- src/FSharp.Control.AsyncSeq/AssemblyInfo.fs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/FSharp.Control.AsyncSeq.Profile7/AssemblyInfo.fs b/src/FSharp.Control.AsyncSeq.Profile7/AssemblyInfo.fs index 08e7776..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.16" - let [] InformationalVersion = "2.0.16" + 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 efc382a..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.16" - let [] InformationalVersion = "2.0.16" + let [] Version = "2.0.17" + let [] InformationalVersion = "2.0.17"