@@ -25,15 +25,15 @@ module AsyncSeq =
2525 yield invalidOp " " }
2626
2727
28- let DEFAULT_TIMEOUT_MS = 2000
28+ let DEFAULT_TIMEOUT_MS = 500
2929
3030let randomDelayMs ( minMs : int ) ( maxMs : int ) ( s : AsyncSeq < 'a >) =
3131 let rand = new Random( int DateTime.Now.Ticks)
3232 let randSleep = async { do ! Async.Sleep( rand.Next( minMs, maxMs)) }
3333 AsyncSeq.zipWith ( fun _ a -> a) ( AsyncSeq.replicateInfiniteAsync randSleep) s
3434
3535let randomDelayDefault ( s : AsyncSeq < 'a >) =
36- randomDelayMs 0 50 s
36+ randomDelayMs 0 10 s
3737
3838let randomDelayMax m ( s : AsyncSeq < 'a >) =
3939 randomDelayMs 0 m s
@@ -66,7 +66,7 @@ let EQ (a:AsyncSeq<'a>) (b:AsyncSeq<'a>) =
6666let runTimeout ( timeoutMs : int ) ( a : Async < 'a >) : 'a =
6767 Async.RunSynchronously ( a, timeoutMs)
6868
69- let runTest a = runTimeout 5000 a
69+ let runTest a = runTimeout 1000 a
7070
7171type Assert with
7272
@@ -264,7 +264,7 @@ let ``AsyncSeq.cache should work``() =
264264[<Test>]
265265let ``AsyncSeq.cache does not slow down late consumers`` () =
266266 let src =
267- AsyncSeq.initInfiniteAsync ( fun _ -> Async.Sleep 1000 )
267+ AsyncSeq.initInfiniteAsync ( fun _ -> Async.Sleep 10 )
268268 |> AsyncSeq.cache
269269 let consume initialDelay amount =
270270 async {
@@ -281,11 +281,11 @@ let ``AsyncSeq.cache does not slow down late consumers``() =
281281 // The first to start will take 10s to consume 10 items
282282 consume 0 10
283283 // The second should take no time to consume 5 items, starting 5s later, as the first five items have already been cached.
284- consume 5000 5
284+ consume 50 5
285285 ]
286286 |> Async.RunSynchronously
287- Assert.LessOrEqual( abs( times.[ 0 ] - 10.0 ), 2.0 f , " Sanity check: lead consumer should take 10s " )
288- Assert.LessOrEqual( times.[ 1 ], 2.0 , " Test purpose: follower should only read cached items" )
287+ Assert.LessOrEqual( abs( times.[ 0 ] - 0.1 ), 0.1 f , " Sanity check: lead consumer should take ~100ms " )
288+ Assert.LessOrEqual( times.[ 1 ], 0.1 , " Test purpose: follower should only read cached items" )
289289
290290[<Test>]
291291let ``AsyncSeq.unfoldAsync`` () =
@@ -577,10 +577,10 @@ let ``AsyncSeq.bufferByCountAndTime should not block`` () =
577577 let op =
578578 asyncSeq {
579579 while true do
580- do ! Async.Sleep 1000
580+ do ! Async.Sleep 10
581581 yield 0
582582 }
583- |> AsyncSeq.bufferByCountAndTime 10 1000
583+ |> AsyncSeq.bufferByCountAndTime 10 100
584584 |> AsyncSeq.take 3
585585 |> AsyncSeq.iter ( ignore)
586586
@@ -591,17 +591,17 @@ let ``AsyncSeq.bufferByCountAndTime should not block`` () =
591591 Async.StartWithContinuations( op, ignore, ignore, ignore, cts.Token)
592592 watch.Stop()
593593 cts.Cancel( false )
594- Assert.Less ( watch.ElapsedMilliseconds, 1000 L )
594+ Assert.Less ( watch.ElapsedMilliseconds, 100 L )
595595
596596[<Test>]
597597let ``AsyncSeq.bufferByTime should not block`` () =
598598 let op =
599599 asyncSeq {
600600 while true do
601- do ! Async.Sleep 1000
601+ do ! Async.Sleep 10
602602 yield 0
603603 }
604- |> AsyncSeq.bufferByTime 1000
604+ |> AsyncSeq.bufferByTime 100
605605 |> AsyncSeq.take 3
606606 |> AsyncSeq.iter ( ignore)
607607
@@ -612,15 +612,15 @@ let ``AsyncSeq.bufferByTime should not block`` () =
612612 Async.StartWithContinuations( op, ignore, ignore, ignore, cts.Token)
613613 watch.Stop()
614614 cts.Cancel( false )
615- Assert.Less ( watch.ElapsedMilliseconds, 1000 L )
615+ Assert.Less ( watch.ElapsedMilliseconds, 100 L )
616616
617617// let s = asyncSeq {
618618// yield 1
619619// yield 2
620- // do! Async.Sleep 100
620+ // do! Async.Sleep 10
621621// yield 3
622622// yield 4
623- // do! Async.Sleep 100
623+ // do! Async.Sleep 10
624624// yield 5
625625// yield 6
626626// }
@@ -900,7 +900,7 @@ let ``AsyncSeq.mergeChoice``() =
900900[<Test>]
901901let ``AsyncSeq.merge should be fair`` () =
902902 let s1 = asyncSeq {
903- do ! Async.Sleep 10
903+ do ! Async.Sleep 1
904904 yield 1
905905 }
906906 let s2 = asyncSeq {
@@ -916,7 +916,7 @@ let ``AsyncSeq.merge should be fair 2``() =
916916 yield 1
917917 }
918918 let s2 = asyncSeq {
919- do ! Async.Sleep 10
919+ do ! Async.Sleep 1
920920 yield 2
921921 }
922922 let actual = AsyncSeq.merge s1 s2
@@ -963,7 +963,7 @@ let ``AsyncSeq.collect works``() =
963963
964964[<Test>]
965965let ``AsyncSeq.initInfinite scales`` () =
966- AsyncSeq.initInfinite string |> AsyncSeq.take 1000 |> AsyncSeq.iter ignore |> Async.RunSynchronously
966+ AsyncSeq.initInfinite string |> AsyncSeq.take 100 |> AsyncSeq.iter ignore |> Async.RunSynchronously
967967
968968[<Test>]
969969let ``AsyncSeq.initAsync`` () =
@@ -1037,7 +1037,7 @@ let ``AsyncSeq.distinctUntilChangedWithAsync``() =
10371037[<Test>]
10381038let ``AsyncSeq.takeUntil should complete immediately with completed signal`` () =
10391039 let s = asyncSeq {
1040- do ! Async.Sleep 10
1040+ do ! Async.Sleep 1
10411041 yield 1
10421042 yield 2
10431043 }
@@ -1063,7 +1063,7 @@ let ``AsyncSeq.skipUntil should not skip with completed signal``() =
10631063 let expected = [ 1 ; 2 ; 3 ; 4 ] |> AsyncSeq.ofSeq
10641064 let actual =
10651065 asyncSeq {
1066- do ! Async.Sleep 100
1066+ do ! Async.Sleep 10
10671067 yield ! expected
10681068 }
10691069 |> AsyncSeq.skipUntilSignal AsyncOps.unit
@@ -1089,7 +1089,7 @@ let ``AsyncSeq.toBlockingSeq should work length 0``() =
10891089[<Test>]
10901090let ``AsyncSeq.toBlockingSeq should work length 2 with sleep`` () =
10911091 let s = asyncSeq { yield 1
1092- do ! Async.Sleep 10
1092+ do ! Async.Sleep 1
10931093 yield 2 } |> AsyncSeq.toBlockingSeq |> Seq.toList
10941094 Assert.True(( s = [ 1 ; 2 ]))
10951095
@@ -1120,7 +1120,7 @@ let ``AsyncSeq.toBlockingSeq should be cancellable``() =
11201120 use! a = Async.OnCancel( fun x -> incr cancelCount)
11211121 while true do
11221122 yield 1
1123- do ! Async.Sleep 10
1123+ do ! Async.Sleep 1
11241124 }
11251125
11261126 let asSeq = aseq |> AsyncSeq.toBlockingSeq
@@ -1130,15 +1130,15 @@ let ``AsyncSeq.toBlockingSeq should be cancellable``() =
11301130 Assert.AreEqual( canMoveNext, true )
11311131 Assert.AreEqual( cancelCount.Value, 0 )
11321132 enum .Dispose()
1133- System.Threading.Thread.Sleep( 1000 ) // wait for task cancellation to be effective
1133+ System.Threading.Thread.Sleep( 100 ) // wait for task cancellation to be effective
11341134 Assert.AreEqual( cancelCount.Value, 1 )
11351135
11361136[<Test>]
11371137let ``AsyncSeq.while should allow do at end`` () =
11381138 let s1 = asyncSeq {
11391139 while false do
11401140 yield 1
1141- do ! Async.Sleep 10
1141+ do ! Async.Sleep 1
11421142 }
11431143 Assert.True( true )
11441144
@@ -1243,17 +1243,17 @@ let ``Async.mergeAll should work``() =
12431243let ``Async.mergeAll should perform well`` () =
12441244 let mergeTest n =
12451245 [ for i in 1 .. n ->
1246- asyncSeq{ do ! Async.Sleep 1000 ;
1246+ asyncSeq{ do ! Async.Sleep 500 ;
12471247 yield i } ]
12481248 |> AsyncSeq.mergeAll
12491249 |> AsyncSeq.toListSynchronously
12501250
1251- Assert.DoesNotThrow( fun _ -> mergeTest 1000 |> ignore)
1251+ Assert.DoesNotThrow( fun _ -> mergeTest 500 |> ignore)
12521252
12531253[<Test>]
12541254let ``Async.mergeAll should be fair`` () =
12551255 let s1 = asyncSeq {
1256- do ! Async.Sleep 1000
1256+ do ! Async.Sleep 300
12571257 yield 1
12581258 }
12591259 let s2 = asyncSeq {
@@ -1532,11 +1532,11 @@ let ``AsyncSeq.iterAsyncParallel should propagate exception`` () =
15321532let ``AsyncSeq.iterAsyncParallel should cancel and not block forever when run in parallel with another exception - throwing Async`` () =
15331533
15341534 let handle x = async {
1535- do ! Async.Sleep 50
1535+ do ! Async.Sleep 5
15361536 }
15371537
15381538 let fakeAsync = async {
1539- do ! Async.Sleep 500
1539+ do ! Async.Sleep 50
15401540 return " fakeAsync"
15411541 }
15421542
@@ -1546,7 +1546,7 @@ let ``AsyncSeq.iterAsyncParallel should cancel and not block forever when run in
15461546 match batch with
15471547 | Choice1Of2 batch ->
15481548 if ( Seq.isEmpty batch) then
1549- do ! Async.Sleep 500
1549+ do ! Async.Sleep 50
15501550 yield ! loop()
15511551 else
15521552 yield batch
@@ -1612,7 +1612,7 @@ let ``AsyncSeq.iterAsyncParallelThrottled should throttle`` () =
16121612 let c = Interlocked.Increment count
16131613 if c > parallelism then
16141614 return failwith " oh no"
1615- do ! Async.Sleep 10
1615+ do ! Async.Sleep 1
16161616 Interlocked.Decrement count |> ignore
16171617 return () })
16181618 |> Async.RunSynchronously
@@ -2141,12 +2141,12 @@ let ``AsyncSeq.fold with empty sequence should return seed``() =
21412141
21422142[<Test>]
21432143let ``AsyncSeq.ofSeq should work with large sequence`` () =
2144- let largeSeq = seq { 1 .. 1000 }
2144+ let largeSeq = seq { 1 .. 100 }
21452145 let asyncSeq = AsyncSeq.ofSeq largeSeq
21462146 let result = asyncSeq |> AsyncSeq.toListAsync |> Async.RunSynchronously
2147- Assert.AreEqual( 1000 , result.Length)
2147+ Assert.AreEqual( 100 , result.Length)
21482148 Assert.AreEqual( 1 , result.[ 0 ])
2149- Assert.AreEqual( 1000 , result.[ 999 ])
2149+ Assert.AreEqual( 100 , result.[ 99 ])
21502150
21512151[<Test>]
21522152let ``AsyncSeq.mapAsync should preserve order with async transformations`` () =
0 commit comments