/src/wrappers/glib/library/utilities/g_timer.e
Specman e | 68 lines | 44 code | 13 blank | 11 comment | 0 complexity | 024c6c48e91d5a0eda0d452ac391f947 MD5 | raw file
1indexing 2 copyright: "(C) 2005 Paolo Redaelli " 3 license: "LGPL v2 or later" 4 date: "$Date:$" 5 revision: "$REvision:$" 6 7class G_TIMER 8 9inherit C_STRUCT redefine default_create end 10 11insert GTIMER_EXTERNALS undefine default_create end 12 13-- creation make 14 15feature {} -- 16 struct_size: INTEGER is 17 external "C inline use <glib.h>" 18 alias "sizeof(GTimer)" 19 end 20 21feature -- Creation 22 default_create is --, make is 23 -- Creates a new timer, and starts timing 24 do 25 handle := g_timer_new 26 end 27 28 dispose is 29 do 30 g_timer_destroy (handle) 31 handle := default_pointer 32 end 33 34feature 35 start is 36 -- (Re)starts timing 37 do 38 g_timer_start(handle) 39 end 40 41 stop is 42 -- Marks an end time 43 do 44 g_timer_stop (handle) 45 end 46 47 continue is 48 -- Resumes a timer that has previously been stopped 49 require 50 -- TODO is_stopped 51 do 52 g_timer_continue (handle) 53 end 54 55 elapsed: REAL is 56 -- If timer has been started but not stopped, obtains the 57 -- time since the timer was started. If timer has been 58 -- stopped, obtains the elapsed time between the time it was 59 -- started and the time it was stopped. Result unit is 60 -- seconds elapsed, including any fractional part 61 local 62 microseconds: REAL 63 do 64 Result:= g_timer_elapsed (handle, $microseconds) 65 end 66 67end 68