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
76d2475f
Commit
76d2475f
authored
9 years ago
by
Lennart Kolmodin
Browse files
Options
Downloads
Patches
Plain Diff
Silence some warnings in benchmarks/Get.hs
parent
112a1a5d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
benchmarks/Get.hs
+16
-7
16 additions, 7 deletions
benchmarks/Get.hs
with
16 additions
and
7 deletions
benchmarks/Get.hs
+
16
−
7
View file @
76d2475f
...
...
@@ -8,21 +8,17 @@ module Main where
import
Control.DeepSeq
import
Control.Exception
(
evaluate
)
import
Control.Monad.Trans
(
liftIO
)
import
Criterion.Main
import
qualified
Data.ByteString
as
S
import
qualified
Data.ByteString.Char8
as
C8
import
qualified
Data.ByteString.Lazy
as
L
import
Data.Char
(
ord
)
import
Data.Monoid
(
Monoid
(
mappend
,
mempty
))
import
Data.Word
(
Word8
,
Word16
,
Word32
)
import
Data.Word
(
Word8
)
import
Control.Applicative
import
Data.Binary.Get
import
Data.Binary
(
get
)
import
qualified
Data.Serialize.Get
as
Cereal
import
qualified
Data.Serialize
as
Cereal
import
qualified
Data.Attoparsec.ByteString
as
A
import
qualified
Data.Attoparsec.ByteString.Lazy
as
AL
...
...
@@ -86,16 +82,24 @@ main = do
whnf
(
runTest
(
getWord8N16A
mega
))
oneMegabyteLBS
]
checkBracket
::
Int
->
Int
checkBracket
x
|
x
==
bracketCount
=
x
|
otherwise
=
error
"argh!"
runTest
::
Get
a
->
L
.
ByteString
->
a
runTest
decoder
inp
=
runGet
decoder
inp
runCereal
::
Cereal
.
Get
a
->
C8
.
ByteString
->
a
runCereal
decoder
inp
=
case
Cereal
.
runGet
decoder
inp
of
Right
a
->
a
Left
err
->
error
err
runAtto
::
AL
.
Parser
a
->
C8
.
ByteString
->
a
runAtto
decoder
inp
=
case
A
.
parseOnly
decoder
inp
of
Right
a
->
a
Left
err
->
error
err
runAttoL
::
Show
a
=>
AL
.
Parser
a
->
L
.
ByteString
->
a
runAttoL
decoder
inp
=
case
AL
.
parse
decoder
inp
of
AL
.
Done
_
r
->
r
a
->
error
(
show
a
)
...
...
@@ -108,15 +112,20 @@ oneMegabyte = S.replicate mega $ fromIntegral $ ord 'a'
oneMegabyteLBS
::
L
.
ByteString
oneMegabyteLBS
=
L
.
fromChunks
[
oneMegabyte
]
mega
::
Int
mega
=
1024
*
1024
-- 100k of brackets
bracketTest
::
L
.
ByteString
->
Int
bracketTest
inp
=
runTest
bracketParser
inp
bracketCount
::
Int
bracketCount
=
fromIntegral
$
L
.
length
brackets
`
div
`
2
brackets
::
L
.
ByteString
brackets
=
L
.
fromChunks
[
C8
.
concat
(
L
.
toChunks
bracketsInChunks
)]
bracketsInChunks
::
L
.
ByteString
bracketsInChunks
=
L
.
fromChunks
(
replicate
chunksOfBrackets
oneChunk
)
where
oneChunk
=
"((()((()()))((()(()()()()()()()(((()()()()(()()(()(()())))))()((())())))()())(((())())(()))))()(()))"
...
...
@@ -143,9 +152,9 @@ bracketParser_cereal = cont <|> return 0
bracketParser_atto
::
A
.
Parser
Int
bracketParser_atto
=
cont
<|>
return
0
where
cont
=
do
v
<-
some
(
do
A
.
word8
40
cont
=
do
v
<-
some
(
do
_
<-
A
.
word8
40
n
<-
bracketParser_atto
A
.
word8
41
_
<-
A
.
word8
41
return
$!
n
+
1
)
return
$!
sum
v
...
...
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