indexing description: "[ A label which displays the frames per second. ]" date: "$Date$" revision: "$Revision$" class EM_FPS_LABEL inherit EM_LABEL redefine next_frame end EM_TIME_SINGLETON export {NONE} all end create make feature {NONE} -- Initialisation make is -- Initialise default values. do make_from_text ("000.0 fps") set_foreground_color (create {EM_COLOR}.make_white) set_background_color (create {EM_COLOR}.make_black) end feature {NONE} -- Implementation fps_count: INTEGER -- Number of calls until next calculation fps_last_call: INTEGER -- Last call of draw in millisecond next_frame is -- Recalculates actual frame rate and saves it in label-text. local fps_string: STRING do fps_count := fps_count + 1 if fps_count \\ 10 = 0 then fps_string := (10000 / ( time.ticks - fps_last_call )).out fps_string.keep_head (4) fps_string := fps_string + " fps" fps_last_call := time.ticks set_text (fps_string) end end end