Skip to content

Fix benchmark build #196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions bench/BenchAll.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import qualified "bytestring" Data.ByteString.Lazy as OldL
import Foreign

import System.Random
import Paths_bench_bytestring


------------------------------------------------------------------------------
Expand Down Expand Up @@ -133,7 +134,7 @@ benchFE name = benchBE name . P.liftFixedToBounded
{-# INLINE benchBE #-}
benchBE :: String -> BoundedPrim Int -> Benchmark
benchBE name e =
bench (name ++" (" ++ show nRepl ++ ")") $ benchIntEncodingB nRepl e
bench (name ++" (" ++ show nRepl ++ ")") $ whnfIO (benchIntEncodingB nRepl e)

-- We use this construction of just looping through @n,n-1,..,1@ to ensure that
-- we measure the speed of the encoding and not the speed of generating the
Expand Down Expand Up @@ -166,7 +167,7 @@ w :: Int -> Word8
w = fromIntegral

hashWord8 :: Word8 -> Word8
hashWord8 = fromIntegral . hashInt . w
hashWord8 = fromIntegral . hashInt . fromIntegral

partitionStrict p = nf (S.partition p) . randomStrict $ mkStdGen 98423098
where randomStrict = fst . S.unfoldrN 10000 (Just . random)
Expand Down
53 changes: 48 additions & 5 deletions bench/bench-bytestring.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,34 @@ executable bench-bytestring-builder
hs-source-dirs: . ..
main-is: BenchAll.hs

build-depends: base >= 4 && < 5
build-depends: base >= 4.4 && < 5
, ghc-prim
, deepseq >= 1.2
, criterion >= 0.5
, blaze-textual == 0.2.*
-- There is no point using blaze-builder-0.4+ as that
-- version is just a wrapper around bytestring itself,
-- abd so a comparison benchmark would have no purpose.
, blaze-builder == 0.3.*
-- we require bytestring due to benchmarking against
-- blaze-textual, which uses blaze-builder
, bytestring >= 0.9
, random
other-modules:
Data.ByteString
Data.ByteString.Builder
Data.ByteString.Builder.ASCII
Data.ByteString.Builder.Extra
Data.ByteString.Builder.Internal
Data.ByteString.Builder.Prim
Data.ByteString.Builder.Prim.ASCII
Data.ByteString.Builder.Prim.Binary
Data.ByteString.Builder.Prim.Internal
Data.ByteString.Builder.Prim.Internal.Base16
Data.ByteString.Builder.Prim.Internal.Floating
Data.ByteString.Builder.Prim.Internal.UncheckedShifts
Data.ByteString.Internal
Data.ByteString.Lazy
Data.ByteString.Lazy.Internal
Data.ByteString.Short.Internal
Data.ByteString.Unsafe
Paths_bench_bytestring

-- cabal complains about ../ dirs. However, this is better than symlinks,
-- which probably don't work on windows.
Expand All @@ -63,6 +78,15 @@ executable bench-bytestring-builder
-fdicts-cheap
-fspec-constr-count=6

-- Since blaze-builder-0.4+ is just a wrapper around bytestring, we prefer
-- building with blaze-builder-0.3.*. However blaze-builder-0.3.* isn't
-- compatible with GHC-8.4+, so we relax the version bounds when building
-- with these GHC versions.
if impl(ghc >= 8.4)
build-depends: blaze-builder >= 0.3 && < 0.5
else
build-depends: blaze-builder == 0.3.*
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, it seemed suboptimal to disable so many benchmarks when building with GHC-8.4+. Instead, I have relaxed the version constraint on blaze-builder when building with those GHC versions.

The comparison with blaze-builder isn't going to be very useful when using GHC-8.4+, but it shouldn't hurt either.


-- flags for the decimal integer serialization code
if impl(ghc >= 6.11)
if !flag(integer-simple)
Expand Down Expand Up @@ -133,6 +157,25 @@ executable bench-builder-boundscheck
-fdicts-cheap
-fspec-constr-count=6
default-language: Haskell98
other-modules:
Data.ByteString
Data.ByteString.Builder
Data.ByteString.Builder.ASCII
Data.ByteString.Builder.Extra
Data.ByteString.Builder.Internal
Data.ByteString.Builder.Prim
Data.ByteString.Builder.Prim.ASCII
Data.ByteString.Builder.Prim.Binary
Data.ByteString.Builder.Prim.Internal
Data.ByteString.Builder.Prim.Internal.Base16
Data.ByteString.Builder.Prim.Internal.Floating
Data.ByteString.Builder.Prim.Internal.UncheckedShifts
Data.ByteString.Internal
Data.ByteString.Lazy
Data.ByteString.Lazy.Internal
Data.ByteString.Short.Internal
Data.ByteString.Unsafe
Paths_bench_bytestring

--executable bench-builder-csv
-- hs-source-dirs: .. .
Expand Down