Haskell function execution time

前端 未结 6 1890
予麋鹿
予麋鹿 2020-12-12 15:35

Is there a simple method to compute time of function execution in Haskell?

6条回答
  •  鱼传尺愫
    2020-12-12 16:03

    https://github.com/chrissound/FuckItTimer

    start' <- start
    timerc start' "begin"
    print "hello"
    timerc start' "after printing hello"
    benchmark
    timerc start' "end"
    end <- getVals start'
    forM_ (timert end) putStrLn
    

    Outputs:

    "hello"
    begin -> after printing hello: 0.000039555s
    after printing hello -> end: 1.333936928s
    

    This seems to work fine for my very simple usecase.

提交回复
热议问题