
That would be fun to share ! Look forward to learning what’s different On Sat, Sep 25, 2021 at 3:51 AM Branimir Maksimovic < branimir.maksimovic@gmail.com> wrote:
It is mine lib for https://www.volomp.com I work now here https://www.rt-rk.com on this http://www.vti.mod.gov.rs/index.php?view=actuality&type=projects&category=1&id=72
I guess that if I port it to Haskell purely from CPP, I won’t have problems with copyright?
Greetings, Branimir
On 25.09.2021., at 09:22, Branimir Maksimovic < branimir.maksimovic@gmail.com> wrote:
Let’s compare: 1000 parallel connections 100k requests
yesod : 7658 recs/sec Errors 85808 Timeouted 0
Mine:: 12699 recs/sec Errors 0 Timeouted 0
10k connections, 100k requests: yesod: 5205 recs/sec Errors 81152 Timeouted 3842
Mine: 8160 recs/sec Errors 0 Timeouted 46
Sources: Yesod: / HomeR GET |]
instance Yesod HelloWorld
getHomeR :: Handler () getHomeR = do number <- liftIO (randomIO :: IO Float) let txt = pack $ "hello world " ++ show number sendResponse (txt:: Text)
main :: IO () main = warp 3838 HelloWorld
Mine: import Sockets import Foreign.C.String import Data.IORef import Control.Concurrent
main = do ref <- newIORef 1 s <- socket defaultCallbacks { constructor = \ci -> set_cb ci defaultCallbacks { done_connected = binded ref, done_reading = process } } pl <- epoll 1000 pl1 <- epoll 1000 pl2 <- epoll 1000 pl3 <- epoll 1000 listen s "8080" pl_accept pl s pl_accept pl1 s pl_accept pl2 s pl_accept pl3 s let run pl = do forkIO $ run_loop pl (-1) run pl run pl1 run pl2 run_loop pl3 (-1)
binded ref pl s = do i <- readIORef ref putStrLn $ "connection nr:"++show i writeIORef ref (i+1) pl_read pl s return 0
process pl s buf len = do str <- peekCStringLen (buf,fromIntegral len) ip <- client s str1 <- peekCString ip putStrLn $ "from "++str1++" \ngot "++str write pl s "Hello World!!!\r\n" return 0
if using -threaded performance is *worse*.
Greetings, Branimir.
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.