<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="">just to translate all thing into Haskell, I have it whole in Rust currently:<div class=""><a href="https://github.com/bmaxa/web_server_rust" class="">https://github.com/bmaxa/web_server_rust</a></div><div class=""><br class=""></div><div class="">Greets, Branimir.<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 26.09.2021., at 17:27, Carter Schonwald <<a href="mailto:carter.schonwald@gmail.com" class="">carter.schonwald@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="auto" class="">That would be fun to share ! Look forward to learning what’s different </div><div class=""><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Sep 25, 2021 at 3:51 AM Branimir Maksimovic <<a href="mailto:branimir.maksimovic@gmail.com" class="">branimir.maksimovic@gmail.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space" class="">It is mine lib for <a href="https://www.volomp.com/" target="_blank" class="">https://www.volomp.com</a><div class="">I work now here <a href="https://www.rt-rk.com/" target="_blank" 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" target="_blank" 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</div></div><div style="word-wrap:break-word;line-break:after-white-space" class=""><div class=""><br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On 25.09.2021., at 09:22, Branimir Maksimovic <<a href="mailto:branimir.maksimovic@gmail.com" target="_blank" class="">branimir.maksimovic@gmail.com</a>> wrote:</div><br class=""><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></div>_______________________________________________<br class="">
Haskell-Cafe mailing list<br class="">
To (un)subscribe, modify options or view archives go to:<br class="">
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank" class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br class="">
Only members subscribed via the mailman list are allowed to post.</blockquote></div></div>
</div></blockquote></div><br class=""></div></body></html>