nikita
nikita

Reputation: 31

How can I use INTERVAL() to measure elapsed time?

Could anyone help me figure out how to check which loop is faster - FOR or REPEAT, using Etime and interval function?

do:
    etime(yes).
    repeat i = 1 to 5:
       display '123'.
    end. 
    end1 = etime.
    display "etime for repeat block" end1 - start1. 
end.

Instead of using end1-start1 I would like to use interval function to find the elapsed time. Thank you.

Upvotes: 0

Views: 2613

Answers (1)

Tom Bascom
Tom Bascom

Reputation: 14020

You need to declare datetime variables and use the "now" function.

define variable dt1 as datetime no-undo.
define variable dt2 as datetime no-undo.

dt1 = now.

pause 3.

dt2 = now.

display interval( dt2, dt1, "milliseconds" ).

Place the code that you want to test where the PAUSE statement is.

(You will need many, many more than 5 iterations to get a meaningful result.)

Upvotes: 1

Related Questions