diff -r 87ee1be17d27 -r f85243bf890e gameServer/stresstest2.hs --- a/gameServer/stresstest2.hs Sun Dec 19 20:45:15 2010 +0300 +++ b/gameServer/stresstest2.hs Sun Dec 19 13:31:55 2010 -0500 @@ -6,7 +6,7 @@ import System.IO import Control.Concurrent import Network -import Control.OldException +import Control.Exception import Control.Monad import System.Random @@ -14,28 +14,22 @@ import System.Posix #endif -session1 nick room = ["NICK", nick, "", "PROTO", "32", ""] - - - -testing = Control.OldException.handle print $ do - putStrLn "Start" +testing = Control.Exception.handle print $ do + delay <- randomRIO (100::Int, 300) + threadDelay delay sock <- connectTo "127.0.0.1" (PortNumber 46631) + hClose sock - num1 <- randomRIO (70000::Int, 70100) - num2 <- randomRIO (0::Int, 2) - num3 <- randomRIO (0::Int, 5) - let nick1 = 'n' : show num1 - let room1 = 'r' : show num2 - mapM_ (\x -> hPutStrLn sock x >> hFlush sock >> randomRIO (300::Int, 590) >>= threadDelay) $ session1 nick1 room1 - mapM_ (\x -> hPutStrLn sock x >> hFlush sock) $ concatMap (\x -> ["CHAT_MSG", show x, ""]) [1..] - hClose sock - putStrLn "Finish" - -forks = testing +forks i = do + delay <- randomRIO (50::Int, 190) + if i `mod` 10 == 0 then putStr (show i) else putStr "." + hFlush stdout + threadDelay delay + forkIO testing + forks (i + 1) main = withSocketsDo $ do #if !defined(mingw32_HOST_OS) installHandler sigPIPE Ignore Nothing; #endif - forks + forks 1