I am trying to write something like
let timeit (x:'a->'b) =
let start = System.DateTime.Now
x
let duration = System.DateTime.Now - start
printfn "time usage = %A" duration.Milliseconds
()
it works for
let matrixtest() =
let x = vector[1.;2.;4.]
let y = matrix[[1.;2.;4.;];[3.;4.;9.;]]
printfn "%A" (y * x)
()
but not for
let rec fib x =
match x with
| 0 | 1 -> 1
| n -> fib (n-1) + fib (n-2)
sa F# is static typed.
Any idea? Thanks.
Even in the matrix case you need to apply the function to a value. Try this:
Aequitarum Custos is right about using the
StopWatchclass, though.