Questions tagged [haskell-criterion]

Criterion is a library for benchmarking Haskell code. For questions related to (N)Hibernate Criteria, use the [criteria] tag.

Links

46 questions
5
votes
1 answer

How to use stack bench?

Just tried to run the benchmarks on a project that I have converted from cabal to stack. Running stack bench just prints out project-name-version: benchmarks with no further output. Do I have to pass additional flags to stack to see the criterion…
fho
  • 6,787
  • 26
  • 71
4
votes
1 answer

Benchmarking IO action with Criterion

I want to know how long it takes my program to read a 12.9MB .wav file into memory. The function that reads a file into memory looks as follows: import qualified Data.ByteString as BS getSamplesFromFileAsBS :: FilePath -> IO…
Thomas Vanhelden
  • 879
  • 8
  • 20
4
votes
1 answer

Profiling executable with criterion

I need to profile a large number of haskell executables, hopefully in parallel. I was able to get the clock time with measure and measTime from the Criterion library, but couldn't get measCpuTime or any GC report to work (measCpuTime returns a time…
rem
  • 893
  • 4
  • 18
4
votes
0 answers

What is the workflow of threadscope in actual projects?

I have a cabal benchmark that uses criterion to generate reports, and I also need to use threadscope to revise the parallelism. I just got it setup, so it's only 4 functions, about 8 seconds of execution, and just from that the eventlog file's size…
MasterMastic
  • 20,711
  • 12
  • 68
  • 90
4
votes
2 answers

Initialize benchmark in criterion and exclude initialization time from results

I need to benchmark some code inside IO, and criterion supports that pretty well. But I want to perform few initialization steps (different for each benchmark). The naive approach: main = defaultMain [ bench "the first" $ do initTheFirst …
Yuras
  • 13,856
  • 1
  • 45
  • 58
4
votes
1 answer

Performance of reservoir sampling vs. getting the length of a list and picking random elements

I have written two functions to pick a random element out of a list of unknown length. The first uses reservoir sampling (with a reservoir of size 1), and the second gets the length of the list to pick a random index and return it. For some reason,…
Antoine
  • 5,158
  • 1
  • 24
  • 37
3
votes
1 answer

Why only minor change to function design radically changes result of criterion benchmark?

I have two source files which are doing roughly the same. The only difference is that in the first case function is passed as a parameter and in the second one - value. First case: module Main where import Data.Vector.Unboxed as UB import qualified…
superstate
  • 173
  • 8
3
votes
1 answer

Asynchronous code runs slower than synchronous version in haskell

Benchmarking the following: #!/usr/bin/env stack -- stack --resolver lts-16.2 script --package async --package criterion import Control.Concurrent.Async (async, replicateConcurrently_) import Control.Monad …
3
votes
2 answers

Creating multiple Criterion Benchmarks at once

This code compiles and runs without problems: module Main where import Criterion.Main main :: IO () main = defaultMain [env (return $ [1,2]) (\is -> bgroup "group" (benchmarks is))] timesTwo :: Int -> Int timesTwo i = 2…
haskellHQ
  • 1,027
  • 6
  • 15
3
votes
2 answers

Cabal install criterion out of memory

I'm running on a container with 768MB ram and 512 MB swap space. I can't increase either of this. cabal install criterion always gives Failed during the building phase. The exception was: ExitFailure (-9) This may be due to an out-of-memory…
jorgen
  • 3,425
  • 4
  • 31
  • 53
3
votes
1 answer

Passing command line arguments to the benhmark program using stack

I'm using stack as a build tool, and criterion as benchmarking library. To run the benchmarks I execute the following command: stack bench Criterion accepts command line arguments to specify where the output should be written to. I would like to…
Damian Nadales
  • 4,907
  • 1
  • 21
  • 34
3
votes
0 answers

GHC Haskell performance of IPv4 address rendering

I recently built a library for handling IPv4 address in haskell. I have written two functions to render an IPv4 address to Text and I am surprised that the naive approach outperforms the approach that I actually thought about. Here are the relevant…
2
votes
1 answer

Using Criterion in Haskell

I am very new to Haskell. I am trying to use Criterion to get performance data. My Main module is as follows: module Main where import SingleThreadedBlockChain import Data.Time.Clock.System (getSystemTime) import System.IO (readFile) import…
S. Dale
  • 46
  • 5
2
votes
1 answer

How to fully evaluate a recursive data type using Control.DeepSeq in Haskell?

I am trying to benchmark (with Criterion) a function, which uses a recursive data type. I found a similar question with an answer that I haven't been able to apply for my case. For non-recursive data types, the following works: data ExampleDataType1…
ProgrammerPotato
  • 505
  • 1
  • 4
  • 11
2
votes
1 answer

Could not find module ‘Criterion.Main’

I have copied the following code from criterion tutorial: import Criterion.Main -- The function we're benchmarking. fib m | m < 0 = error "negative!" | otherwise = go m where go 0 = 0 go 1 = 1 go n = go (n-1) + go (n-2) --…