[Haskell-cafe] warp vs scotty + some benchmark numbers
Miro Karpis
miroslav.karpis at gmail.com
Sat Apr 12 21:22:01 UTC 2014
Hi,
I'm trying to make a small benchmarking for warp and scotty (later with
json/no-json text performance test). My client is a Qt c++ application. I
made a minimum code in both Haskell and C++. The problem is the numbers I'm
getting.
(Benchmark::pong-warp) - total requests: 10000 , send/received in msec:
3848
(Benchmark::pong-scotty) - total requests: 10000 , send/received in msec:
3814
Only sending 10k requests from my c++ client takes around 1 sec.
What I don't understand is:
a) how is it possible that scotty is so close to warp (in this run it even
wins)?
b) 10k requests I'm getting in approximately 4 seconds.
Here<http://www.yesodweb.com/blog/2011/03/preliminary-warp-cross-language-benchmarks>is
one 2 years old benchmark with 80k/second. Why is there so big
difference?
I'm running on macbook-pro 16g, 2.3 GHz
Scotty and warp is compiled with: -O2 -threaded
--scotty
import Web.Scotty
import Data.Monoid (mconcat)
main = scotty 3005 $ do
get "/" $ do
text "pong"
--warp
import Network.Wai(responseLBS, Application)
import Network.HTTP.Types(status200)
import Network.Wai.Handler.Warp (run)
app :: Application
app _ = return $ responseLBS
status200
[("Content-Type", "text/plain")]
"pong"
main :: IO ()
main = do
let port = 3000
putStrLn $ "Listening on port " ++ show port
run port app
--c++ client sample (Qt)
simStart = QDateTime().currentMSecsSinceEpoch();
for(int i=0; i<requests; i++){
QNetworkReply *reply = manager->get(QNetworkRequest(url));
QEventLoop eventLoop;
QObject::connect(manager, SIGNAL(finished(QNetworkReply *)),
&eventLoop, SLOT(quit()));
eventLoop.exec();
QObject::disconnect(manager, SIGNAL(finished(QNetworkReply
*)), &eventLoop, SLOT(quit()));
}
qDebug() << "(Benchmark::pong) - total requests: " << requests <<
", send in msec: " << (QDateTime().currentMSecsSinceEpoch()-simStart);
cheers,
miro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140412/67e27ac0/attachment.html>
More information about the Haskell-Cafe
mailing list