gameServer/stresstest.hs
changeset 5058 4229507909d6
parent 5003 db4726bf9205
child 5077 7915668502a6
equal deleted inserted replaced
5057:b47ebd95c885 5058:4229507909d6
    17 session1 nick room = ["NICK", nick, "", "PROTO", "32", "", "PING", "", "CHAT", "lobby 1", "", "CREATE_ROOM", room, "", "CHAT", "room 1", "", "QUIT", "creator", ""]
    17 session1 nick room = ["NICK", nick, "", "PROTO", "32", "", "PING", "", "CHAT", "lobby 1", "", "CREATE_ROOM", room, "", "CHAT", "room 1", "", "QUIT", "creator", ""]
    18 session2 nick room = ["NICK", nick, "", "PROTO", "32", "", "LIST", "", "JOIN_ROOM", room, "", "CHAT", "room 2", "", "PART", "", "CHAT", "lobby after part", "", "QUIT", "part-quit", ""]
    18 session2 nick room = ["NICK", nick, "", "PROTO", "32", "", "LIST", "", "JOIN_ROOM", room, "", "CHAT", "room 2", "", "PART", "", "CHAT", "lobby after part", "", "QUIT", "part-quit", ""]
    19 session3 nick room = ["NICK", nick, "", "PROTO", "32", "", "LIST", "", "JOIN_ROON", room, "", "CHAT", "room 2", "", "QUIT", "quit", ""]
    19 session3 nick room = ["NICK", nick, "", "PROTO", "32", "", "LIST", "", "JOIN_ROON", room, "", "CHAT", "room 2", "", "QUIT", "quit", ""]
    20 
    20 
    21 emulateSession sock s = do
    21 emulateSession sock s = do
    22     mapM_ (\x -> hPutStrLn sock x >> hFlush sock >> randomRIO (3000000::Int, 5900000) >>= threadDelay) s
    22     mapM_ (\x -> hPutStrLn sock x >> hFlush sock >> randomRIO (1000000::Int, 3000000) >>= threadDelay) s
    23     hFlush sock
    23     hFlush sock
    24     threadDelay 225000
    24     threadDelay 225000
    25 
    25 
    26 testing = Control.OldException.handle print $ do
    26 testing = Control.OldException.handle print $ do
    27     putStrLn "Start"
    27     putStrLn "Start"
    38         2 -> emulateSession sock $ session3 nick1 room1
    38         2 -> emulateSession sock $ session3 nick1 room1
    39     hClose sock
    39     hClose sock
    40     putStrLn "Finish"
    40     putStrLn "Finish"
    41 
    41 
    42 forks = forever $ do
    42 forks = forever $ do
    43     delay <- randomRIO (30000::Int, 59000)
    43     delay <- randomRIO (30000::Int, 69000)
    44     threadDelay delay
    44     threadDelay delay
    45     forkIO testing
    45     forkIO testing
    46 
    46 
    47 main = withSocketsDo $ do
    47 main = withSocketsDo $ do
    48 #if !defined(mingw32_HOST_OS)
    48 #if !defined(mingw32_HOST_OS)