File: GoodReadFile.hs

package info (click to toggle)
haskell-criterion 1.6.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 360 kB
  • sloc: haskell: 1,891; javascript: 811; makefile: 3
file content (12 lines) | stat: -rw-r--r-- 412 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
-- This example demonstrates how to correctly benchmark a function
-- that performs lazy I/O.

import Criterion.Main

main :: IO ()
main = defaultMain [
    -- Because we are using nfIO here, the entire file will be read on
    -- each benchmark loop iteration.  This will cause the associated
    -- file handle to be eagerly closed every time.
    bench "nfIO readFile" $ nfIO (readFile "GoodReadFile.hs")
  ]