You can use either statistics(runtime) :
Returns information about the runtime, in milliseconds.
This is the sum of the runtime for all threads in the Erlang runtime and therefore may be longer than a wall clock.
Or statistics(wall_clock) :
Returns wall clock information. wall_clock can be used in the same way as runtime, except that in real time it is measured as the opposite of runtime or processor time.
In both cases, you need to call them at the beginning of your program to reset their timers. When you want to print the elapsed time, do the following:
{_, Time1} = statistics(runtime).
or
{_, Time2} = statistics(wall_clock).
Accordingly, and then you will have time in Time1 or Time2 . For more information see erlang:statistics/1
Note. . If you want the total time elapsed since the Erlang virtual machine was launched, you can take the first element from the tuple: {Total_Time, Time_Since_Last_Call} = statistics(wall_clock).
A. Sarid
source share