Skip to content

Instantly share code, notes, and snippets.

{-# LANGUAGE BangPatterns #-}
module Network.ConnectionPool
( withConnection
, newConnectionPool
, closeConnectionPool
, ConnectionPool
) where
------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Applicative
import Control.Monad.Trans
import qualified Data.ByteString.Lazy as L
import Snap.Http.Server
import Snap.Types
import Snap.Util.FileServe
{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE PackageImports #-}
module Snaplets where
import "monads-fd" Control.Monad.State
import Data.ByteString (ByteString)
import Data.Dynamic
import Data.Map (Map)
import Snap.Types
Tue Aug 24 18:04 2010 Time and Allocation Profiling Report (Final)
pongserver +RTS -p -A4M -qg0 -qb -g1 -RTS
total time = 24.18 secs (1209 ticks @ 20 ms)
total alloc = 13,228,877,164 bytes (excludes profiling overheads)
COST CENTRE MODULE %time %alloc
sendData Snap.Internal.Http.Server.LibevBackend 15.2 0.0
catchError' :: Monad m =>
Iteratee a m b
-> (SomeException -> Iteratee a m b)
-> Iteratee a m b
catchError' iter h = do
step <- lift $ runIteratee iter
go step
where
go step =
@gregorycollins
gregorycollins / criterion-collection-sample-output.txt
Created February 1, 2011 23:50
Sample output from "criterion-collection"
warming up
estimating clock resolution...
mean is 11.41351 us (80001 iterations)
found 7313 outliers among 79999 samples (9.1%)
1159 (1.4%) high mild
6137 (7.7%) high severe
estimating cost of a clock call...
mean is 166.3485 ns (77 iterations)
found 8 outliers among 77 samples (10.4%)
3 (3.9%) high mild
@gregorycollins
gregorycollins / gist:826935
Created February 15, 2011 01:30
Hashtable benchmark results feb 14 2011
ByteString keys between 8-32 characters long (ascii, hex digits). Test run on a Macbook Pro (2.53GHz Intel Core i5) running GHC 6.12.3.
$ ./dist/build/ucoll-benchmark/ucoll-benchmark +RTS -N -A4M
Results for Insert Performance
------------------------------------------------------------------------------
Data structure Data.Map
Input Sz Mean (secs) Stddev (secs) 95% (secs) Max (secs)
@gregorycollins
gregorycollins / new iteratee bind.hs
Created February 16, 2011 21:52
new iteratee bind
instance Monad m => Monad (Iteratee a m) where
return x = yield x (Chunks [])
m >>= f = bind m f
{-# INLINE bind #-}
bind :: Monad m =>
Iteratee a m b
-> (b -> Iteratee a m c)
-> Iteratee a m c
{-# LANGUAGE BangPatterns #-}
-----------------------------------------------------------------------------
-- |
-- Copyright: 2010 John Millikin
-- License: MIT
--
-- Maintainer: jmillikin@gmail.com
-- Portability: portable
--
@gregorycollins
gregorycollins / EnumeratorFork.hs
Created April 20, 2011 19:12
Forking an enumerator computation
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Concurrent (killThread)
import Control.Concurrent.BoundedChan
import Control.Concurrent.Thread
import Control.Exception (SomeException)
import Control.Monad.CatchIO
import Control.Monad.Trans
import Prelude hiding (catch)
import qualified Data.Enumerator.List as E