Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #13879
| Newsgroups | comp.programming |
|---|---|
| From | Branimir Maksimovic <branimir.maksimovic@gmail.com> |
| Subject | Dilemma |
| Message-ID | <ttE3J.44939$3p3.30652@fx16.iad> (permalink) |
| Organization | usenet-news.net |
| Date | 2021-09-25 12:19 +0000 |
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*.
Dilemma:
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
--
7-77-777
Evil Sinner!
Back to comp.programming | Previous | Next — Next in thread | Find similar | Unroll thread
Dilemma Branimir Maksimovic <branimir.maksimovic@gmail.com> - 2021-09-25 12:19 +0000
Re: Dilemma Peter <peterxpercival@hotmail.com> - 2021-09-25 19:39 +0100
Re: Dilemma Branimir Maksimovic <branimir.maksimovic@gmail.com> - 2021-09-25 19:16 +0000
csiph-web