/tutorial/time/example2.e
Specman e | 42 lines | 34 code | 4 blank | 4 comment | 2 complexity | 61a467ac92c301fda4f93d40c9d0bdeb MD5 | raw file
1class EXAMPLE2 2 -- 3 -- This example shows how to know about time variation using 4 -- class TIME. 5 -- 6 7create {ANY} 8 make 9 10feature {} 11 make 12 local 13 time1, time2: TIME; clock: CLOCK; clock_value1, clock_value2, periods: INTEGER; seconds: REAL 14 do 15 if clock.value >= 0 then 16 clock_value1 := clock.value 17 end 18 time1.update 19 from 20 time2.update 21 until 22 time2 > time1 23 loop 24 time2.update 25 end 26 27 clock_value2 := clock.value 28 io.put_string("Elapsed time: ") 29 io.put_real_format(time1.elapsed_seconds(time2).floor, 0) 30 io.put_string(" seconds%N") 31 if clock_value1 >= 0 then 32 io.put_string("Elapsed time in number of clock periods: ") 33 periods := clock_value2 - clock_value1 34 io.put_integer(periods) 35 io.put_string(" (sec: ") 36 seconds := periods / clock.periods_per_second 37 io.put_real(seconds) 38 io.put_string(")%N") 39 end 40 end 41 42end -- class EXAMPLE2