Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
8 changes: 4 additions & 4 deletions src/FSharp.Control.AsyncSeq.Profile7/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ open System.Reflection
[<assembly: AssemblyTitleAttribute("FSharp.Control.AsyncSeq.Profile7")>]
[<assembly: AssemblyProductAttribute("FSharp.Control.AsyncSeq")>]
[<assembly: AssemblyDescriptionAttribute("Asynchronous sequences for F#")>]
[<assembly: AssemblyVersionAttribute("2.0.14")>]
[<assembly: AssemblyFileVersionAttribute("2.0.14")>]
[<assembly: AssemblyVersionAttribute("2.0.17")>]
[<assembly: AssemblyFileVersionAttribute("2.0.17")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] Version = "2.0.14"
let [<Literal>] InformationalVersion = "2.0.14"
let [<Literal>] Version = "2.0.17"
let [<Literal>] InformationalVersion = "2.0.17"
8 changes: 4 additions & 4 deletions src/FSharp.Control.AsyncSeq/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ open System.Reflection
[<assembly: AssemblyTitleAttribute("FSharp.Control.AsyncSeq")>]
[<assembly: AssemblyProductAttribute("FSharp.Control.AsyncSeq")>]
[<assembly: AssemblyDescriptionAttribute("Asynchronous sequences for F#")>]
[<assembly: AssemblyVersionAttribute("2.0.14")>]
[<assembly: AssemblyFileVersionAttribute("2.0.14")>]
[<assembly: AssemblyVersionAttribute("2.0.17")>]
[<assembly: AssemblyFileVersionAttribute("2.0.17")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] Version = "2.0.14"
let [<Literal>] InformationalVersion = "2.0.14"
let [<Literal>] Version = "2.0.17"
let [<Literal>] InformationalVersion = "2.0.17"
35 changes: 34 additions & 1 deletion tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqPerf.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<int, int> list = [ S 500 ]
// let exp2 : int list list = [ [] ; [] ; [] ; [] ]

let toSeq (xs:Choice<int, int> 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


100 changes: 82 additions & 18 deletions tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -448,27 +448,91 @@ let ``AsyncSeq.bufferByTimeAndCount empty``() =

[<Test>]
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<int, int> list = [ S 500 ]
// let exp2 : int list list = [ [] ; [] ; [] ; [] ]

let toSeq (xs:Choice<int, int> 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
//
//[<Test>]
//let ``AsyncSeq.bufferByTime2`` () =
//
// let Y = Choice1Of2
// let S = Choice2Of2
// let sleepMs = 100
//
// let toSeq (xs:Choice<int, int> 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))

[<Test>]
let ``AsyncSeq.bufferByCountAndTime should not block`` () =
Expand Down