File: GoodReadFile.hs

package info (click to toggle)
haskell-criterion 1.6.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 352 kB
  • sloc: haskell: 1,839; javascript: 811; makefile: 2
file content (12 lines) | stat: -rw-r--r-- 412 bytes parent folder | download | duplicates (6)
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")
  ]