Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
binary
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Glasgow Haskell Compiler
Packages
binary
Commits
69915d0a
Commit
69915d0a
authored
9 years ago
by
Lennart Kolmodin
Browse files
Options
Downloads
Patches
Plain Diff
Add new benchmark suite for encoding.
parent
6c67458b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
benchmarks/Put.hs
+117
-0
117 additions, 0 deletions
benchmarks/Put.hs
binary.cabal
+13
-0
13 additions, 0 deletions
binary.cabal
with
130 additions
and
0 deletions
benchmarks/Put.hs
0 → 100644
+
117
−
0
View file @
69915d0a
{-# LANGUAGE CPP, ExistentialQuantification #-}
module
Main
(
main
)
where
import
Control.DeepSeq
import
Control.Exception
(
evaluate
)
import
Criterion.Main
import
qualified
Data.ByteString
as
S
import
qualified
Data.ByteString.Char8
as
C
import
qualified
Data.ByteString.Lazy
as
L
import
Data.Binary
import
Data.Binary.Put
main
::
IO
()
main
=
do
evaluate
$
rnf
[
rnf
bigIntegers
,
rnf
smallIntegers
,
rnf
smallByteStrings
,
rnf
smallStrings
,
rnf
word8s
]
defaultMain
[
bench
"small Integers"
$
whnf
(
run
.
fromIntegers
)
smallIntegers
,
bench
"big Integers"
$
whnf
(
run
.
fromIntegers
)
bigIntegers
,
bench
"[small Integer]"
$
whnf
(
run
.
put
)
smallIntegers
,
bench
"[big Integer]"
$
whnf
(
run
.
put
)
bigIntegers
,
bench
"small ByteStrings"
$
whnf
(
run
.
fromByteStrings
)
smallByteStrings
,
bench
"[small ByteString]"
$
whnf
(
run
.
put
)
smallByteStrings
,
bench
"small Strings"
$
whnf
(
run
.
fromStrings
)
smallStrings
,
bench
"[small String]"
$
whnf
(
run
.
put
)
smallStrings
,
bench
"Word8s"
$
whnf
(
run
.
fromWord8s
)
word8s
,
bench
"[Word8]"
$
whnf
(
run
.
put
)
word8s
,
bench
"Word16s"
$
whnf
(
run
.
fromWord16s
)
word16s
,
bench
"[Word16]"
$
whnf
(
run
.
put
)
word16s
,
bench
"Word32s"
$
whnf
(
run
.
fromWord32s
)
word32s
,
bench
"[Word32]"
$
whnf
(
run
.
put
)
word32s
,
bench
"Word64s"
$
whnf
(
run
.
fromWord64s
)
word64s
,
bench
"[Word64]"
$
whnf
(
run
.
put
)
word64s
]
where
run
=
L
.
length
.
runPut
-- Input data
smallIntegers
::
[
Integer
]
smallIntegers
=
[
0
..
10000
]
{-# NOINLINE smallIntegers #-}
bigIntegers
::
[
Integer
]
bigIntegers
=
[
max
..
max
+
10000
]
where
max
::
Integer
max
=
fromIntegral
(
maxBound
::
Word64
)
{-# NOINLINE bigIntegers #-}
smallByteStrings
::
[
S
.
ByteString
]
smallByteStrings
=
replicate
10000
$
C
.
pack
"abcdefghi"
{-# NOINLINE smallByteStrings #-}
smallStrings
::
[
String
]
smallStrings
=
replicate
10000
"abcdefghi"
{-# NOINLINE smallStrings #-}
word8s
::
[
Word8
]
word8s
=
take
10000
$
cycle
[
minBound
..
maxBound
]
{-# NOINLINE word8s #-}
word16s
::
[
Word16
]
word16s
=
take
10000
$
cycle
[
minBound
..
maxBound
]
{-# NOINLINE word16s #-}
word32s
::
[
Word32
]
word32s
=
take
10000
$
cycle
[
minBound
..
maxBound
]
{-# NOINLINE word32s #-}
word64s
::
[
Word64
]
word64s
=
take
10000
$
cycle
[
minBound
..
maxBound
]
{-# NOINLINE word64s #-}
------------------------------------------------------------------------
-- Benchmarks
fromIntegers
::
[
Integer
]
->
Put
fromIntegers
[]
=
return
()
fromIntegers
(
x
:
xs
)
=
put
x
>>
fromIntegers
xs
fromByteStrings
::
[
S
.
ByteString
]
->
Put
fromByteStrings
[]
=
return
()
fromByteStrings
(
x
:
xs
)
=
put
x
>>
fromByteStrings
xs
fromStrings
::
[
String
]
->
Put
fromStrings
[]
=
return
()
fromStrings
(
x
:
xs
)
=
put
x
>>
fromStrings
xs
fromWord8s
::
[
Word8
]
->
Put
fromWord8s
[]
=
return
()
fromWord8s
(
x
:
xs
)
=
put
x
>>
fromWord8s
xs
fromWord16s
::
[
Word16
]
->
Put
fromWord16s
[]
=
return
()
fromWord16s
(
x
:
xs
)
=
put
x
>>
fromWord16s
xs
fromWord32s
::
[
Word32
]
->
Put
fromWord32s
[]
=
return
()
fromWord32s
(
x
:
xs
)
=
put
x
>>
fromWord32s
xs
fromWord64s
::
[
Word64
]
->
Put
fromWord64s
[]
=
return
()
fromWord64s
(
x
:
xs
)
=
put
x
>>
fromWord64s
xs
This diff is collapsed.
Click to expand it.
binary.cabal
+
13
−
0
View file @
69915d0a
...
...
@@ -124,6 +124,19 @@ benchmark get
build-depends: array, containers
ghc-options: -O2 -Wall
benchmark put
type: exitcode-stdio-1.0
hs-source-dirs: src benchmarks
main-is: Put.hs
build-depends:
base >= 3.0 && < 5,
bytestring,
criterion == 1.*,
deepseq
-- build dependencies from using binary source rather than depending on the library
build-depends: array, containers
ghc-options: -O2 -Wall
benchmark generics-bench
type: exitcode-stdio-1.0
hs-source-dirs: src benchmarks
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment