1 #!/home/ralph/src/devuan/rrqforth/rrqforth
3 # This example adds the words:
4 # time0 = variable for holding a time stamp
5 # time = function to read of current time; seconds since epoch
6 # marktime = function that sets time0 from current time
7 # telltime = function that prints the difference between current time and time0
8 # longloop = test function for simple timing test
10 INPUT @ READ-WORD time0 CREATE DROP 0 , ( variable time0 )
12 : time ( -- s ; seconds since epoch )
13 0 [ SYSTEM USE SYS_TIME TFA>CFA , ]
16 : marktime ( -- ; set time0 from current time )
20 : telltime ( -- s ; read off time since time0 )
25 S" Takes " TELL marktime
29 telltime S" seconds" TELL NL EMIT
33 " Test run a tight loop of " TELL DUP . " cycles" TELL NL EMIT