This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "snap-server".

The branch, master has been updated
       via  775935eb4a1065a7c4ed32a3d8ae6118dfd3219c (commit)
      from  e33282b149be786b099cd2263c32756d61e19b9c (commit)


Summary of changes:
 test/benchmark/Benchmark.hs                        |   12 +----
 .../Snap/Internal/Http/Parser/Benchmark.hs         |   47 ++++++++++---------
 test/benchmark/Snap/Internal/Http/Parser/Data.hs   |   24 ++++++++++
 test/snap-server-testsuite.cabal                   |    3 +-
 4 files changed, 52 insertions(+), 34 deletions(-)
 create mode 100644 test/benchmark/Snap/Internal/Http/Parser/Data.hs

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 775935eb4a1065a7c4ed32a3d8ae6118dfd3219c
Author: Aycan iRiCAN <[email protected]>
Date:   Fri Sep 3 15:06:30 2010 +0300

    added ChunkedTransferEncoding benchmark.

diff --git a/test/benchmark/Benchmark.hs b/test/benchmark/Benchmark.hs
index 7fb7461..8278750 100644
--- a/test/benchmark/Benchmark.hs
+++ b/test/benchmark/Benchmark.hs
@@ -1,15 +1,7 @@
 module Main where
 
-import Criterion.Main
-
+import           Criterion.Main
 import qualified Snap.Internal.Http.Parser.Benchmark as PB
 
-fib :: Int -> Int
-fib 0 = 0
-fib 1 = 1
-fib n = fib (n-1) + fib (n-2)
-
 main :: IO ()
-main = defaultMain [
-       PB.benchmarks
-       ]
+main = defaultMain [ PB.benchmarks ]
diff --git a/test/benchmark/Snap/Internal/Http/Parser/Benchmark.hs 
b/test/benchmark/Snap/Internal/Http/Parser/Benchmark.hs
index 1eac323..7e815d9 100644
--- a/test/benchmark/Snap/Internal/Http/Parser/Benchmark.hs
+++ b/test/benchmark/Snap/Internal/Http/Parser/Benchmark.hs
@@ -1,36 +1,39 @@
 {-# LANGUAGE BangPatterns #-}
 {-# LANGUAGE OverloadedStrings #-}
 {-# LANGUAGE ScopedTypeVariables #-}
+{-# LANGUAGE PackageImports #-}
 
 module Snap.Internal.Http.Parser.Benchmark 
        ( benchmarks )
        where
 
-import           Criterion.Main
-import           Snap.Internal.Http.Parser
-import           Data.ByteString (ByteString)
-import qualified Data.ByteString as S
-import qualified Snap.Iteratee as SI
-import qualified Control.Exception as E
-import           Data.Attoparsec hiding (Result(..))
+import             Criterion.Main hiding (run)
+import             Snap.Internal.Http.Parser
+import             Data.ByteString (ByteString)
+import qualified   Data.ByteString as S
+import qualified   Snap.Iteratee as SI
+import qualified   Control.Exception as E
+import             Data.Attoparsec hiding (Result(..))
+import             Snap.Internal.Http.Parser.Data
+import "monads-fd" Control.Monad.Identity
+import             Data.Iteratee
+import             Data.Iteratee.WrappedByteString
+import             Snap.Iteratee hiding (take, foldl', filter)
+import qualified Data.ByteString.Lazy.Char8 as L
 
-req1 = S.concat 
-       [ "GET /favicon.ico HTTP/1.1\r\n"
-       , "Host: 0.0.0.0=5000\r\n"
-       , "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) 
Gecko/2008061015 Firefox/3.0\r\n"
-       , "Accept: 
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n"
-       , "Accept-Language: en-us,en;q=0.5\r\n"
-       , "Accept-Encoding: gzip,deflate\r\n"
-       , "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n"
-       , "Keep-Alive: 300\r\n"
-       , "Connection: keep-alive\r\n"
-       , "\r\n" ]
+parseGet ::  IO ()
+parseGet = SI.enumBS parseGetData parseRequest >>= SI.run >> return ()
 
-test1 ::  IO ()
-test1 = do
-  i <- SI.enumBS req1 parseRequest
+parseChunked :: IO ()
+parseChunked = do
+  c <- toChunked parseChunkedData
+  i <- SI.enumLBS c (readChunkedTransferEncoding stream2stream)
   f <- SI.run i
   return ()
 
+-- utils
+toChunked lbs = writeChunkedTransferEncoding (enumLBS lbs) stream2stream >>= 
run >>= return . fromWrap
+
 benchmarks = bgroup "parser"
-             [ bench "firefoxget" $ whnfIO test1 ]
\ No newline at end of file
+             [ bench "firefoxget" $ whnfIO parseGet
+             , bench "readChunkedTransferEncoding" $ whnfIO parseChunked ]
diff --git a/test/benchmark/Snap/Internal/Http/Parser/Data.hs 
b/test/benchmark/Snap/Internal/Http/Parser/Data.hs
new file mode 100644
index 0000000..d9b0857
--- /dev/null
+++ b/test/benchmark/Snap/Internal/Http/Parser/Data.hs
@@ -0,0 +1,24 @@
+{-# LANGUAGE OverloadedStrings #-}
+
+module Snap.Internal.Http.Parser.Data 
+    ( parseGetData
+    , parseChunkedData
+    )
+    where
+
+import           Data.ByteString (ByteString)
+import qualified Data.ByteString.Char8 as S
+import qualified Data.ByteString.Lazy.Char8 as L
+parseGetData = S.concat 
+               [ "GET /favicon.ico HTTP/1.1\r\n"
+               , "Host: 0.0.0.0=5000\r\n"
+               , "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) 
Gecko/2008061015 Firefox/3.0\r\n"
+               , "Accept: 
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n"
+               , "Accept-Language: en-us,en;q=0.5\r\n"
+               , "Accept-Encoding: gzip,deflate\r\n"
+               , "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n"
+               , "Keep-Alive: 300\r\n"
+               , "Connection: keep-alive\r\n"
+               , "\r\n" ]
+
+parseChunkedData = L.fromChunks ["In the beginning, everything was void, and 
J.H.W.H. Conway began to create numbers.", "Conway said, \"Let there be two 
rules which bring forth all numbers larege and small.", "This shall be the 
first rule: Every number corresponds to two sets of previously created numbers, 
such that no member of the left set is greater than or equal to any member of 
the right set.", "And the second rule shall be this: One number is less than or 
equal to another number if and only if no member of the first number \'s left 
set is greater than or equal to the second number, and no member of the second 
number\'s right set is less than or equal to the first number.\" And Conway 
examined these two rules he had made, and behold! They were very good.", "And 
the first number was created from the void left set and the void right set. 
Conway called this number \"zero,\" and said that it shall be a sign to 
separate positive numbers from negative numbers.", "Conway prove
 d that zero was less than or equal to zero, end he saw that it was good.", 
"And the evening and the morning were the day of zero.", "On the next day, two 
more numbers were created, one with zero as its left set and one with zero as 
its right set. And Conway called the former number \"one,\" and the latter he 
called \"minus one.\" And he proved that minus one is less than but not equal 
to zero and zero is less than but not equal to one.", "And the evening day.", 
"And Conway said, \"Let the numbers be added to each other in this wise: The 
left set of the sum of two numbers shall be the sums of all left parts of each 
number with the other; and in like manner the right set shall be from the right 
parts, each according to its kind.\" Conway proved that every number plus zero 
is unchanged, and he saw that addition was good.", "And the evening and the 
morning were the third day."]
diff --git a/test/snap-server-testsuite.cabal b/test/snap-server-testsuite.cabal
index a904a15..4b70052 100644
--- a/test/snap-server-testsuite.cabal
+++ b/test/snap-server-testsuite.cabal
@@ -224,5 +224,4 @@ Executable benchmark
      base >= 4 && < 5,
      network == 2.2.1.7,
      HTTP >= 4000.0.9 && < 4001,
-     criterion >= 0.5 && <0.6
-   
+     criterion >= 0.5 && <0.6     
-----------------------------------------------------------------------


hooks/post-receive
-- 
snap-server
_______________________________________________
Snap mailing list
[email protected]
http://mailman-mail5.webfaction.com/listinfo/snap

Reply via email to