<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">It is mine lib for <a href="https://www.volomp.com" class="">https://www.volomp.com</a><div class="">I work now here <a href="https://www.rt-rk.com" class="">https://www.rt-rk.com</a></div><div class="">on this <a href="http://www.vti.mod.gov.rs/index.php?view=actuality&type=projects&category=1&id=72" class="">http://www.vti.mod.gov.rs/index.php?view=actuality&type=projects&category=1&id=72</a></div><div class=""><br class=""></div><div class="">I guess that if I port it to Haskell purely from CPP, I won’t have problems with copyright?</div><div class=""><br class=""></div><div class="">Greetings, Branimir<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 25.09.2021., at 09:22, Branimir Maksimovic <<a href="mailto:branimir.maksimovic@gmail.com" class="">branimir.maksimovic@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Let’s compare:<br class="">1000 parallel connections 100k requests<br class=""><br class="">yesod :<br class="">7658 recs/sec<br class="">Errors 85808<br class="">Timeouted 0<br class=""><br class="">Mine::<br class="">12699 recs/sec<br class="">Errors 0<br class="">Timeouted 0<br class=""><br class="">10k connections, 100k requests:<br class="">yesod:<br class="">5205 recs/sec<br class="">Errors 81152<br class="">Timeouted 3842<br class=""><br class="">Mine:<br class="">8160 recs/sec<br class="">Errors 0<br class="">Timeouted 46<br class=""><br class="">Sources:<br class="">Yesod:<br class="">/ HomeR GET<br class="">|]<br class=""><br class="">instance Yesod HelloWorld<br class=""><br class="">getHomeR :: Handler ()<br class="">getHomeR = do<br class=""> number <- liftIO (randomIO :: IO Float)<br class=""> let txt = pack $ "hello world " ++ show number<br class=""> sendResponse (txt:: Text)<br class=""><br class="">main :: IO ()<br class="">main = warp 3838 HelloWorld<br class=""><br class="">Mine:<br class="">import Sockets<br class="">import Foreign.C.String<br class="">import Data.IORef<br class="">import Control.Concurrent<br class=""><br class="">main = do<br class=""> ref <- newIORef 1<br class=""> s <- socket defaultCallbacks {<br class=""> constructor = \ci -> set_cb ci defaultCallbacks {<br class=""> done_connected = binded ref,<br class=""> done_reading = process<br class=""> }<br class=""> }<br class=""> pl <- epoll 1000<br class=""> pl1 <- epoll 1000<br class=""> pl2 <- epoll 1000<br class=""> pl3 <- epoll 1000<br class=""> listen s "8080"<br class=""> pl_accept pl s<br class=""> pl_accept pl1 s<br class=""> pl_accept pl2 s<br class=""> pl_accept pl3 s<br class=""> let run pl = do forkIO $<br class=""> run_loop pl (-1)<br class=""> run pl<br class=""> run pl1<br class=""> run pl2<br class=""> run_loop pl3 (-1)<br class=""><br class="">binded ref pl s = do<br class=""> i <- readIORef ref<br class=""> putStrLn $ "connection nr:"++show i<br class=""> writeIORef ref (i+1)<br class=""> pl_read pl s<br class=""> return 0<br class=""><br class="">process pl s buf len = do<br class=""> str <- peekCStringLen (buf,fromIntegral len)<br class=""> ip <- client s<br class=""> str1 <- peekCString ip<br class=""> putStrLn $ "from "++str1++" \ngot "++str<br class=""> write pl s "Hello World!!!\r\n"<br class=""> return 0<br class=""><br class="">if using -threaded performance is *worse*.<br class=""><br class="">Greetings, Branimir.</div></div></blockquote></div><br class=""></div></body></html>