From 3c2b0cb2799684d4e32ede1cb6a1103bdd5fe690 Mon Sep 17 00:00:00 2001 From: Efim Poberezkin <8711996+efim-poberezkin@users.noreply.github.com> Date: Tue, 15 Feb 2022 15:30:46 +0400 Subject: [PATCH] count each nth iteration --- tests/ChatTests.hs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/ChatTests.hs b/tests/ChatTests.hs index d38e80b19f..d36798acfc 100644 --- a/tests/ChatTests.hs +++ b/tests/ChatTests.hs @@ -9,7 +9,7 @@ import ChatClient import Control.Concurrent (threadDelay) import Control.Concurrent.Async (concurrently_) import Control.Concurrent.STM -import Control.Monad (forever) +import Control.Monad (forever, when) import qualified Data.ByteString as B import Data.Char (isDigit) import Data.Maybe (fromJust) @@ -78,12 +78,16 @@ testStressServer = testChat2' (i * 2 -1, aliceProfile) (i * 2, bobProfile) $ \alice bob -> do connectUsers alice bob - forever $ do - alice <##> bob - atomically $ modifyTVar sentTVar (+ 2) - threadDelay 500 + forever $ loop alice bob sentTVar 0 ) (take 100 ([1 ..] :: [Int])) + where + loop :: TestCC -> TestCC -> TVar Int -> Int -> IO () + loop alice bob sentTVar k = do + alice <##> bob + when (k `mod` 100 == 0) $ atomically $ modifyTVar sentTVar (+ 200) + threadDelay 500 + loop alice bob sentTVar $ k + 1 testAddContact :: IO () testAddContact =