Skip to content

Commit bd6c71b

Browse files
committed
update release notes
1 parent 2f2749f commit bd6c71b

3 files changed

Lines changed: 136 additions & 21 deletions

File tree

RELEASE_NOTES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
### 2.0.16 - 29.09.2017
2+
* Fix previous package deployment
3+
14
### 2.0.15 - 27.09.2017
25
* NEW: AsyncSeq.bufferByTime
36

tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqPerf.fsx

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,54 @@ let collect n =
118118
//run replicate
119119
//run bind
120120
//run bindUnfold
121-
run collect
122-
123-
121+
//run collect
122+
123+
let rec prependToAll (a:'a) (ls:'a list) : 'a list =
124+
match ls with
125+
| [] -> []
126+
| hd::tl -> a::hd::prependToAll a tl
127+
128+
let rec intersperse (a:'a) (ls:'a list) : 'a list =
129+
match ls with
130+
| [] -> []
131+
| hd::tl -> hd::prependToAll a tl
132+
133+
let intercalate (l:'a list) (xs:'a list list) : 'a list =
134+
intersperse l xs |> List.concat
135+
136+
let batch (size:int) (ls:'a list) : 'a list list =
137+
let rec go batch ls =
138+
match ls with
139+
| [] -> [List.rev batch]
140+
| _ when List.length batch = size -> (List.rev batch)::go [] ls
141+
| hd::tl -> go (hd::batch) tl
142+
go [] ls
143+
144+
145+
let Y = Choice1Of2
146+
let S = Choice2Of2
147+
let sleepMs = 100
148+
149+
let toSeq (xs:Choice<int, int> list) = asyncSeq {
150+
for x in xs do
151+
match x with
152+
| Choice1Of2 v -> yield v
153+
| Choice2Of2 s -> do! Async.Sleep s }
154+
155+
for (size,batchSize) in [ (0,0) ; (10,2) ; (30,2) ] do
156+
157+
let expected =
158+
List.init size id
159+
|> batch batchSize
160+
161+
let actual =
162+
expected
163+
|> List.map (List.map Y)
164+
|> intercalate [S sleepMs]
165+
|> toSeq
166+
|> AsyncSeq.bufferByTime sleepMs
167+
|> AsyncSeq.map List.ofArray
168+
|> AsyncSeq.toList
169+
170+
//Assert.True ((actual = expected))
171+
printfn "actual=%A expected=%A" actual expected

tests/FSharp.Control.AsyncSeq.Tests/AsyncSeqTests.fs

Lines changed: 82 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -448,27 +448,91 @@ let ``AsyncSeq.bufferByTimeAndCount empty``() =
448448

449449
[<Test>]
450450
let ``AsyncSeq.bufferByTime`` () =
451-
452-
let s = asyncSeq {
453-
yield 1
454-
yield 2
455-
do! Async.Sleep 100
456-
yield 3
457-
yield 4
458-
do! Async.Sleep 100
459-
yield 5
460-
yield 6
461-
}
462451

463-
let actual =
464-
s
465-
|> AsyncSeq.bufferByTime 100
466-
|> AsyncSeq.map (List.ofArray)
467-
|> AsyncSeq.toList
452+
let Y = Choice1Of2
453+
let S = Choice2Of2
468454

469-
let expected = [ [1;2] ; [3;4] ; [5;6] ]
455+
let timeMs = 100
470456

471-
Assert.True ((actual = expected))
457+
let inp0 = [ ]
458+
let exp0 = [ ]
459+
460+
let inp1 = [ Y 1 ; Y 2 ; S 100 ; Y 3 ; Y 4 ; S 100 ; Y 5 ; Y 6 ]
461+
let exp1 = [ [1;2] ; [3;4] ; [5;6] ]
462+
463+
// let inp2 : Choice<int, int> list = [ S 500 ]
464+
// let exp2 : int list list = [ [] ; [] ; [] ; [] ]
465+
466+
let toSeq (xs:Choice<int, int> list) = asyncSeq {
467+
for x in xs do
468+
match x with
469+
| Choice1Of2 v -> yield v
470+
| Choice2Of2 s -> do! Async.Sleep s }
471+
472+
for (inp,exp) in [ (inp0,exp0) ; (inp1,exp1) ] do
473+
474+
let actual =
475+
toSeq inp
476+
|> AsyncSeq.bufferByTime 100
477+
|> AsyncSeq.map List.ofArray
478+
|> AsyncSeq.toList
479+
480+
let ls = toSeq inp |> AsyncSeq.toList
481+
let actualLs = actual |> List.concat
482+
483+
Assert.True ((actual = exp))
484+
485+
// WARNING: Too timing sensitive
486+
//let rec prependToAll (a:'a) (ls:'a list) : 'a list =
487+
// match ls with
488+
// | [] -> []
489+
// | hd::tl -> a::hd::prependToAll a tl
490+
//
491+
//let rec intersperse (a:'a) (ls:'a list) : 'a list =
492+
// match ls with
493+
// | [] -> []
494+
// | hd::tl -> hd::prependToAll a tl
495+
//
496+
//let intercalate (l:'a list) (xs:'a list list) : 'a list =
497+
// intersperse l xs |> List.concat
498+
//
499+
//let batch (size:int) (ls:'a list) : 'a list list =
500+
// let rec go batch ls =
501+
// match ls with
502+
// | [] -> [List.rev batch]
503+
// | _ when List.length batch = size -> (List.rev batch)::go [] ls
504+
// | hd::tl -> go (hd::batch) tl
505+
// go [] ls
506+
//
507+
//[<Test>]
508+
//let ``AsyncSeq.bufferByTime2`` () =
509+
//
510+
// let Y = Choice1Of2
511+
// let S = Choice2Of2
512+
// let sleepMs = 100
513+
//
514+
// let toSeq (xs:Choice<int, int> list) = asyncSeq {
515+
// for x in xs do
516+
// match x with
517+
// | Choice1Of2 v -> yield v
518+
// | Choice2Of2 s -> do! Async.Sleep s }
519+
//
520+
// for (size,batchSize) in [ (0,0) ; (10,2) ; (100,2) ] do
521+
//
522+
// let expected =
523+
// List.init size id
524+
// |> batch batchSize
525+
//
526+
// let actual =
527+
// expected
528+
// |> List.map (List.map Y)
529+
// |> intercalate [S sleepMs]
530+
// |> toSeq
531+
// |> AsyncSeq.bufferByTime sleepMs
532+
// |> AsyncSeq.map List.ofArray
533+
// |> AsyncSeq.toList
534+
//
535+
// Assert.True ((actual = expected))
472536

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

0 commit comments

Comments
 (0)