mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-04-25 16:22:16 +00:00
add base64 case
This commit is contained in:
@@ -8,6 +8,7 @@ Pick one or group: cabal bench -O2 simplexmq-bench --benchmark-options "-p TRcvQ
|
||||
|
||||
module Main where
|
||||
|
||||
import Bench.Base64
|
||||
import Bench.BsConcat
|
||||
import Bench.Compression
|
||||
import Bench.SNTRUP761
|
||||
@@ -20,5 +21,6 @@ main =
|
||||
[ bgroup "TRcvQueues" benchTRcvQueues,
|
||||
bgroup "SNTRUP761" benchSNTRUP761,
|
||||
bgroup "Compression" benchCompression,
|
||||
bgroup "BsConcat" benchBsConcat
|
||||
bgroup "BsConcat" benchBsConcat,
|
||||
bgroup "Base64" benchBase64
|
||||
]
|
||||
|
||||
49
benchmarks/Bench/Base64.hs
Normal file
49
benchmarks/Bench/Base64.hs
Normal file
@@ -0,0 +1,49 @@
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE PackageImports #-}
|
||||
{-# LANGUAGE TypeApplications #-}
|
||||
|
||||
module Bench.Base64 where
|
||||
|
||||
import Data.ByteString (ByteString)
|
||||
import Test.Tasty.Bench
|
||||
import qualified "base64" Data.Base64.Types as New
|
||||
import qualified "base64" Data.ByteString.Base64 as New
|
||||
import qualified "base64" Data.ByteString.Base64.URL as NewUrl
|
||||
import qualified "base64-bytestring" Data.ByteString.Base64 as Old
|
||||
import qualified "base64-bytestring" Data.ByteString.Base64.URL as OldUrl
|
||||
|
||||
benchBase64 :: [Benchmark]
|
||||
benchBase64 =
|
||||
[ bgroup
|
||||
"encode"
|
||||
[ bench "e-old" $ nf Old.encode decoded,
|
||||
bcompare "e-old" . bench "e-new" $ nf New.encodeBase64' decoded
|
||||
],
|
||||
bgroup
|
||||
"decode"
|
||||
[ bench "d-old" $ nf Old.decode encoded,
|
||||
bcompare "d-old" . bench "d-new" $ nf New.decodeBase64Untyped encoded,
|
||||
bcompare "d-old" . bench "d-typed" $ nf (New.decodeBase64 . New.assertBase64 @New.StdPadded) encoded
|
||||
],
|
||||
bgroup
|
||||
"encode url"
|
||||
[ bench "eu-old" $ nf OldUrl.encode decoded,
|
||||
bcompare "eu-old" . bench "eu-new" $ nf NewUrl.encodeBase64' decoded
|
||||
],
|
||||
bgroup
|
||||
"decode url"
|
||||
[ bench "du-old" $ nf OldUrl.decode encodedUrl,
|
||||
bcompare "du-old" . bench "du-new" $ nf NewUrl.decodeBase64Untyped encodedUrl,
|
||||
bcompare "du-old" . bench "du-typed" $ nf (NewUrl.decodeBase64 . New.assertBase64 @New.UrlPadded) encodedUrl
|
||||
]
|
||||
]
|
||||
|
||||
encoded :: ByteString
|
||||
encoded = "e8JK+8V3fq6kOLqco/SaKlpNaQ7i1gfOrXoqekEl42u4mF8Bgu14T5j0189CGcUhJHw2RwCMvON+qbvQ9ecJAA=="
|
||||
|
||||
encodedUrl :: ByteString
|
||||
encodedUrl = "e8JK-8V3fq6kOLqco_SaKlpNaQ7i1gfOrXoqekEl42u4mF8Bgu14T5j0189CGcUhJHw2RwCMvON-qbvQ9ecJAA=="
|
||||
|
||||
decoded :: ByteString
|
||||
decoded = "{\194J\251\197w~\174\164\&8\186\156\163\244\154*ZMi\SO\226\214\a\206\173z*zA%\227k\184\152_\SOH\130\237xO\152\244\215\207B\EM\197!$|6G\NUL\140\188\227~\169\187\208\245\231\t\NUL"
|
||||
34
package.yaml
34
package.yaml
@@ -175,23 +175,25 @@ benchmarks:
|
||||
source-dirs: benchmarks
|
||||
main: Bench.hs
|
||||
dependencies:
|
||||
- containers
|
||||
- hashable == 1.4.*
|
||||
- hspec
|
||||
- simplexmq
|
||||
- tasty
|
||||
- tasty-bench
|
||||
- tasty-hspec
|
||||
- unliftio
|
||||
- unordered-containers
|
||||
- zstd
|
||||
- base64
|
||||
- base64-bytestring
|
||||
- containers
|
||||
- hashable == 1.4.*
|
||||
- hspec
|
||||
- simplexmq
|
||||
- tasty
|
||||
- tasty-bench
|
||||
- tasty-hspec
|
||||
- unliftio
|
||||
- unordered-containers
|
||||
- zstd
|
||||
ghc-options:
|
||||
- -fproc-alignment=64
|
||||
- -rtsopts
|
||||
- -threaded
|
||||
- -with-rtsopts=-A64m
|
||||
- -with-rtsopts=-N1
|
||||
- -with-rtsopts=-T
|
||||
- -fproc-alignment=64
|
||||
- -rtsopts
|
||||
- -threaded
|
||||
- -with-rtsopts=-A64m
|
||||
- -with-rtsopts=-N1
|
||||
- -with-rtsopts=-T
|
||||
|
||||
ghc-options:
|
||||
# - -haddock
|
||||
|
||||
@@ -749,6 +749,7 @@ benchmark simplexmq-bench
|
||||
type: exitcode-stdio-1.0
|
||||
main-is: Bench.hs
|
||||
other-modules:
|
||||
Bench.Base64
|
||||
Bench.BsConcat
|
||||
Bench.Compression
|
||||
Bench.SNTRUP761
|
||||
@@ -756,7 +757,9 @@ benchmark simplexmq-bench
|
||||
Paths_simplexmq
|
||||
hs-source-dirs:
|
||||
benchmarks
|
||||
ghc-options: -Wall -Wcompat -Werror=incomplete-patterns -Wredundant-constraints -Wincomplete-record-updates -Wincomplete-uni-patterns -Wunused-type-patterns -fproc-alignment=64 -rtsopts -threaded -with-rtsopts=-A64m -with-rtsopts=-N1 -with-rtsopts=-T
|
||||
default-extensions:
|
||||
StrictData
|
||||
ghc-options: -Wall -Wcompat -Werror=incomplete-patterns -Wredundant-constraints -Wincomplete-record-updates -Wincomplete-uni-patterns -Wunused-type-patterns -O2 -fproc-alignment=64 -rtsopts -threaded -with-rtsopts=-A64m -with-rtsopts=-N1 -with-rtsopts=-T
|
||||
build-depends:
|
||||
aeson ==2.2.*
|
||||
, ansi-terminal >=0.10 && <0.12
|
||||
@@ -765,7 +768,8 @@ benchmark simplexmq-bench
|
||||
, async ==2.2.*
|
||||
, attoparsec ==0.14.*
|
||||
, base >=4.14 && <5
|
||||
, base64-bytestring >=1.0 && <1.3
|
||||
, base64
|
||||
, base64-bytestring
|
||||
, case-insensitive ==1.2.*
|
||||
, composition ==1.0.*
|
||||
, constraints >=0.12 && <0.14
|
||||
|
||||
Reference in New Issue
Block a user