Skip to content

Commit

Permalink
Set -fproc-alignment=64 for benchmarks (#577)
Browse files Browse the repository at this point in the history
* Set -fproc-alignment=64 for benchmarks

* Benchmarks: force absurdlong before actual benchmarking
  • Loading branch information
Bodigrim authored Feb 16, 2023
1 parent 0bd68ca commit da6ea8f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions bench/BenchIndices.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ nilEq = (==)

-- lines of 200 letters from a to e, followed by repeated letter f
absurdlong :: S.ByteString
absurdlong = S.replicate 200 0x61 <> S.singleton nl
absurdlong = (S.replicate 200 0x61 <> S.singleton nl
<> S.replicate 200 0x62 <> S.singleton nl
<> S.replicate 200 0x63 <> S.singleton nl
<> S.replicate 200 0x64 <> S.singleton nl
<> S.replicate 200 0x65 <> S.singleton nl
<> S.replicate 200 0x65 <> S.singleton nl)
<> S.replicate 999999 0x66

benchIndices :: Benchmark
benchIndices = bgroup "Indices"
benchIndices = absurdlong `seq` bgroup "Indices"
[ bgroup "ByteString strict first index" $
[ bench "FindIndices" $ nf (listToMaybe . S.findIndices (== nl)) absurdlong
, bench "ElemIndices" $ nf (listToMaybe . S.elemIndices nl) absurdlong
Expand Down
6 changes: 3 additions & 3 deletions bench/BenchShort.hs
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ nilEq = (==)

-- lines of 200 letters from a to e, followed by repeated letter f
absurdlong :: S.ShortByteString
absurdlong = S.replicate 200 0x61 <> S.singleton nl
absurdlong = (S.replicate 200 0x61 <> S.singleton nl
<> S.replicate 200 0x62 <> S.singleton nl
<> S.replicate 200 0x63 <> S.singleton nl
<> S.replicate 200 0x64 <> S.singleton nl
<> S.replicate 200 0x65 <> S.singleton nl
<> S.replicate 200 0x65 <> S.singleton nl)
<> S.replicate 999999 0x66

bench_find_index_second :: ShortByteString -> Maybe Int
Expand All @@ -166,7 +166,7 @@ bench_elem_index_second bs =
-------------

benchShort :: Benchmark
benchShort = bgroup "ShortByteString"
benchShort = absurdlong `seq` bgroup "ShortByteString"
[ bgroup "Small payload"
[ benchB' "mempty" () (const mempty)
, benchB' "UTF-8 String (naive)" "hello world\0" fromString
Expand Down
2 changes: 2 additions & 0 deletions bytestring.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ benchmark bytestring-bench
hs-source-dirs: bench
default-language: Haskell2010
ghc-options: -O2 "-with-rtsopts=-A32m"
if impl(ghc >= 8.6)
ghc-options: -fproc-alignment=64
build-depends: base,
bytestring,
deepseq,
Expand Down

0 comments on commit da6ea8f

Please sign in to comment.