diff --git a/cabal.project b/cabal.project index 42e8057b..0a0c8162 100644 --- a/cabal.project +++ b/cabal.project @@ -14,6 +14,7 @@ packages: servant-server/ servant-swagger/ doc/tutorial/ + flat-64/ -- servant streaming packages: diff --git a/flat-64/LICENSE b/flat-64/LICENSE new file mode 100644 index 00000000..31f0c958 --- /dev/null +++ b/flat-64/LICENSE @@ -0,0 +1,30 @@ +Copyright (c) 2018, Daniel Bergey + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + * Neither the name of Daniel Bergey nor the names of other + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/flat-64/Main.hs b/flat-64/Main.hs new file mode 100644 index 00000000..06433ff2 --- /dev/null +++ b/flat-64/Main.hs @@ -0,0 +1,103 @@ +{-# LANGUAGE TypeOperators #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE OverloadedStrings #-} +module Main where + +import Data.Semigroup +import Data.Text (Text) +import Servant hiding (NotSecure) +import Servant.Server +import Network.Wai.Handler.Warp (defaultSettings, runSettings, + setLogger, setPort) + +import qualified Data.Text as T + +type MainAPI = + "static" :> "1" :> Get '[JSON] Text + :<|> "static" :> "2" :> Get '[JSON] Text + :<|> "static" :> "3" :> Get '[JSON] Text + :<|> "static" :> "4" :> Get '[JSON] Text + :<|> "static" :> "5" :> Get '[JSON] Text + :<|> "static" :> "6" :> Get '[JSON] Text + :<|> "static" :> "7" :> Get '[JSON] Text + :<|> "static" :> "8" :> Get '[JSON] Text + :<|> "static" :> "9" :> Get '[JSON] Text + :<|> "static" :> "10" :> Get '[JSON] Text + :<|> "static" :> "11" :> Get '[JSON] Text + :<|> "static" :> "12" :> Get '[JSON] Text + :<|> "static" :> "13" :> Get '[JSON] Text + :<|> "static" :> "14" :> Get '[JSON] Text + :<|> "static" :> "15" :> Get '[JSON] Text + :<|> "static" :> "16" :> Get '[JSON] Text + :<|> "static" :> "17" :> Get '[JSON] Text + :<|> "static" :> "18" :> Get '[JSON] Text + :<|> "static" :> "19" :> Get '[JSON] Text + :<|> "static" :> "20" :> Get '[JSON] Text + :<|> "static" :> "21" :> Get '[JSON] Text + :<|> "static" :> "22" :> Get '[JSON] Text + :<|> "static" :> "23" :> Get '[JSON] Text + :<|> "static" :> "24" :> Get '[JSON] Text + :<|> "static" :> "25" :> Get '[JSON] Text + :<|> "static" :> "26" :> Get '[JSON] Text + :<|> "static" :> "27" :> Get '[JSON] Text + :<|> "static" :> "28" :> Get '[JSON] Text + :<|> "static" :> "29" :> Get '[JSON] Text + :<|> "static" :> "30" :> Get '[JSON] Text + :<|> "static" :> "31" :> Get '[JSON] Text + :<|> "static" :> "32" :> Get '[JSON] Text + :<|> "static" :> "33" :> Get '[JSON] Text + :<|> "static" :> "34" :> Get '[JSON] Text + :<|> "static" :> "35" :> Get '[JSON] Text + :<|> "static" :> "36" :> Get '[JSON] Text + :<|> "static" :> "37" :> Get '[JSON] Text + :<|> "static" :> "38" :> Get '[JSON] Text + :<|> "static" :> "39" :> Get '[JSON] Text + :<|> "static" :> "40" :> Get '[JSON] Text + :<|> "static" :> "41" :> Get '[JSON] Text + :<|> "static" :> "42" :> Get '[JSON] Text + :<|> "static" :> "43" :> Get '[JSON] Text + :<|> "static" :> "44" :> Get '[JSON] Text + :<|> "static" :> "45" :> Get '[JSON] Text + :<|> "static" :> "46" :> Get '[JSON] Text + :<|> "static" :> "47" :> Get '[JSON] Text + :<|> "static" :> "48" :> Get '[JSON] Text + :<|> "static" :> "49" :> Get '[JSON] Text + :<|> "static" :> "50" :> Get '[JSON] Text + :<|> "static" :> "51" :> Get '[JSON] Text + :<|> "static" :> "52" :> Get '[JSON] Text + :<|> "static" :> "53" :> Get '[JSON] Text + :<|> "static" :> "54" :> Get '[JSON] Text + :<|> "static" :> "55" :> Get '[JSON] Text + :<|> "static" :> "56" :> Get '[JSON] Text + :<|> "static" :> "57" :> Get '[JSON] Text + :<|> "static" :> "58" :> Get '[JSON] Text + :<|> "static" :> "59" :> Get '[JSON] Text + :<|> "static" :> "60" :> Get '[JSON] Text + :<|> "static" :> "61" :> Get '[JSON] Text + :<|> "static" :> "62" :> Get '[JSON] Text + :<|> "static" :> "63" :> Get '[JSON] Text + :<|> "static" :> "64" :> Get '[JSON] Text + +mainServer :: Server MainAPI +mainServer = foo :<|> foo :<|> foo :<|> foo + :<|> foo :<|> foo :<|> foo :<|> foo + :<|> foo :<|> foo :<|> foo :<|> foo + :<|> foo :<|> foo :<|> foo :<|> foo + :<|> foo :<|> foo :<|> foo :<|> foo + :<|> foo :<|> foo :<|> foo :<|> foo + :<|> foo :<|> foo :<|> foo :<|> foo + :<|> foo :<|> foo :<|> foo :<|> foo + :<|> foo :<|> foo :<|> foo :<|> foo + :<|> foo :<|> foo :<|> foo :<|> foo + :<|> foo :<|> foo :<|> foo :<|> foo + :<|> foo :<|> foo :<|> foo :<|> foo + :<|> foo :<|> foo :<|> foo :<|> foo + :<|> foo :<|> foo :<|> foo :<|> foo + :<|> foo :<|> foo :<|> foo :<|> foo + :<|> foo :<|> foo :<|> foo :<|> foo + +foo = return "foo" + +main :: IO () +main = runSettings defaultSettings $ + serveWithContext (Proxy :: Proxy MainAPI) EmptyContext mainServer diff --git a/flat-64/Setup.hs b/flat-64/Setup.hs new file mode 100644 index 00000000..9a994af6 --- /dev/null +++ b/flat-64/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/flat-64/flat-64.cabal b/flat-64/flat-64.cabal new file mode 100644 index 00000000..0f53de63 --- /dev/null +++ b/flat-64/flat-64.cabal @@ -0,0 +1,28 @@ +-- Initial servant-bench.cabal generated by cabal init. For further +-- documentation, see http://haskell.org/cabal/users-guide/ + +name: flat64 +version: 0.1.0.0 +synopsis: Compare build times with different API type structure +-- description: +license: BSD3 +license-file: LICENSE +author: Daniel Bergey +maintainer: bergey@teallabs.org +-- copyright: +category: Development +build-type: Simple +cabal-version: >=1.10 + +executable servant-bench + main-is: Main.hs + -- other-modules: + -- other-extensions: + build-depends: base + , servant + , servant-server + , text + , warp + -- hs-source-dirs: + default-language: Haskell2010 + ghc-options: -fforce-recomp -O2 diff --git a/nix/nixpkgs2.nix b/nix/nixpkgs2.nix new file mode 100644 index 00000000..b298a298 --- /dev/null +++ b/nix/nixpkgs2.nix @@ -0,0 +1,4 @@ +import (builtins.fetchTarball { + url = "https://github.com/NixOS/nixpkgs/archive/2c66a7a6e036971c4847cca424125f55b9eb0b0b.tar.gz"; + sha256 = "sha256:00pdg5mkgqp81n4pfgigd840hvh3fwwkbipcba1p4ds3ffy3xir5"; +}) {} diff --git a/nix/shell2.nix b/nix/shell2.nix new file mode 100644 index 00000000..b621a80e --- /dev/null +++ b/nix/shell2.nix @@ -0,0 +1,20 @@ +{ compiler ? "ghc8107" +, tutorial ? false +, pkgs ? import ./nixpkgs2.nix +}: + + with pkgs; + + let + ghc = haskell.packages.${compiler}.ghcWithPackages (_: []); + docstuffs = python3.withPackages (ps: with ps; [ recommonmark sphinx sphinx_rtd_theme ]); + in + stdenv.mkDerivation { + name = "servant-dev"; + buildInputs = [ ghc zlib python3 wget cabal-install postgresql openssl stack haskellPackages.hspec-discover bench ] + ++ (if tutorial then [docstuffs postgresql] else []); + shellHook = '' + eval $(grep export ${ghc}/bin/ghc) + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"${zlib}/lib"; + ''; + }