/src/wrappers/glib/library/utilities/g_timer.e

http://github.com/tybor/Liberty · Specman e · 68 lines · 44 code · 13 blank · 11 comment · 0 complexity · 024c6c48e91d5a0eda0d452ac391f947 MD5 · raw file

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