How to get a program's running time in Haskell

后端 未结 4 449
臣服心动
臣服心动 2021-02-04 12:10

How can I go about getting a program\'s running time through system time functions in Haskell? I would like to measure the execution time of a whole program and/or an individual

4条回答
  •  孤街浪徒
    2021-02-04 13:06

    Assuming you don't just want to measure the total running time of your program, like so:

     $ time ./A
    

    Then you can time a computation a number of ways in Haskell:

    • Basic timing (e.g. as in the timeit package)
    • Timing in cycles

    For more statistically sound measurement, consider

    • The Criterion package.

    Finally, in all cases, you need to think about lazy evaluation: do you want to measure the cost of fully evaluating whatever data you produce, or just to its outermost constructor?

提交回复
热议问题