Module Timer

Timer is a function timing framework that is used to time the execution time of expressions and functions

Copyright (C) 2020 Nikunj Chawla

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see https://www.gnu.org/licenses/.

val time_exp_res : (unit -> 'a) -> 'a * float

time_exp_res takes in an unevaluated expression using a thunk, times how long it takes for the expression to run, and returns the evaluated expression and the time it took to run in seconds

parameter exp_thunk

The expression to time upon execution of the thunk

returns

A tuple containing the result of the expression and the time it took the expression to run in seconds

val time_exp : (unit -> 'a) -> float

time_exp takes in an unevaluated expression using a thunk, times how long it takes for the expression to run, and returns the time it took to run in seconds

parameter exp_thunk

The expression to time upon execution of the thunk

returns

The time it took the expression to run in seconds

val time_exp_n : int -> (unit -> 'a) -> float

time_exp_n takes in an unevaluated expression using a thunk, times how long it takes for the expression to run n times, and returns the time it took to run in seconds

parameter n

The number of times to test the expression

parameter exp_thunk

The expression to time upon execution of the thunk

returns

The time it took the expression to run n times in seconds

val func_timer_res : (unit -> 'a -> 'b) -> (unit -> 'a) -> 'b * float

func_timer_res takes in an unevaluated, one-argument function using a thunk and its unevaluated input using a thunk, times how long it takes for the function to run with the given input, and returns the function result and the time it took to run in seconds; it may be useful to only provide the first argument so that you can time the same function with various different inputs

parameter fun_thunk

The function thunk to time with the given input upon execution of the thunk

parameter input_thunk

The input to the function to time that will be evaluated upon execution of the thunk

returns

A tuple containing the output of the function and the time it took the function to run in seconds with the given input

val func_timer : (unit -> 'a -> 'b) -> (unit -> 'a) -> float

func_timer takes in an unevaluated, one-argument function using a thunk and its unevaluated input using a thunk, times how long it takes for the function to run with the given input, and returns the time it took to run in seconds; it may be useful to only provide the first argument so that you can time the same function with various different inputs

parameter fun_thunk

The function thunk to time with the given input upon execution of the thunk

parameter input_thunk

The input to the function to time that will be evaluated upon execution of the thunk

returns

The time it took the function to run in seconds with the given input

val func_timer_n : int -> (unit -> 'a -> 'b) -> (unit -> 'a) -> float

func_timer takes in an unevaluated, one-argument function using a thunk and its unevaluated input using a thunk, times how long it takes for the function to run with the given input n times, and returns the time it took to run in seconds; it may be useful to only provide the first argument so that you can time the same function with various different inputs

parameter n

The number of times to test the function with the given input

parameter fun_thunk

The function thunk to time with the given input upon execution of the thunk

parameter input_thunk

The input to the function to time that will be evaluated upon execution of the thunk

returns

The time it took the function to run n times in seconds with the given input