Freeciv-3.1
|
#include <time.h>
#include "log.h"
#include "mem.h"
#include "shared.h"
#include "support.h"
#include "timing.h"
Go to the source code of this file.
Data Structures | |
struct | timer |
Macros | |
#define | CLOCKS_PER_SEC 1000000 /* wild guess!! */ |
#define | N_USEC_PER_SEC 1000000L /* not 1000! :-) */ |
Enumerations | |
enum | timer_state { TIMER_STARTED , TIMER_STOPPED } |
Functions | |
static void | report_clock_failed (struct timer *t) |
static void | report_time_failed (struct timer *t) |
struct timer * | timer_new (enum timer_timetype type, enum timer_use use) |
struct timer * | timer_renew (struct timer *t, enum timer_timetype type, enum timer_use use) |
void | timer_destroy (struct timer *t) |
bool | timer_in_use (struct timer *t) |
void | timer_clear (struct timer *t) |
void | timer_start (struct timer *t) |
void | timer_stop (struct timer *t) |
double | timer_read_seconds (struct timer *t) |
void | timer_usleep_since_start (struct timer *t, long usec) |
enum timer_state |
|
static |
Report if clock() returns -1, but only the first time. Ignore this timer from now on.
Definition at line 109 of file timing.c.
Referenced by timer_start(), and timer_stop().
|
static |
Report if time() returns -1, but only the first time. Ignore this timer from now on.
Definition at line 140 of file timing.c.
Referenced by timer_start(), and timer_stop().
void timer_clear | ( | struct timer * | t | ) |
Reset accumulated time to zero, and stop timer if going. That is, this may be called whether t is started or stopped; in either case the timer is in the stopped state after this function.
Definition at line 212 of file timing.c.
Referenced by send_server_info_to_metaserver(), srv_running(), timer_renew(), and timing_log_real().
void timer_destroy | ( | struct timer * | t | ) |
Free the memory associated with a timer.
Definition at line 191 of file timing.c.
Referenced by adv_settlers_free(), agents_free(), autosaves_callback(), cm_free(), connection_common_close(), dai_manage_taxes(), incoming_client_packets(), load_command(), mapimg_create(), save_game(), savegame3_save(), savegame_load(), send_server_info_to_metaserver(), server_make_connection(), server_quit(), srv_running(), and timing_log_free().
Return whether timer is in use. t may be NULL, in which case returns 0
Definition at line 202 of file timing.c.
Referenced by auto_settlers_player().
struct timer * timer_new | ( | enum timer_timetype | type, |
enum timer_use | use | ||
) |
Allocate a new timer with specified "type" and "use". The timer is created as cleared, and stopped.
Definition at line 157 of file timing.c.
Referenced by cm_init(), connection_ping(), dai_manage_taxes(), load_command(), mapimg_create(), register_agent(), save_game(), savegame3_save(), savegame_load(), send_server_info_to_metaserver(), server_make_connection(), srv_prepare(), and timing_log_init().
double timer_read_seconds | ( | struct timer * | t | ) |
Read value from timer. If the timer is not stopped, this stops the timer, reads it (and accumulates), and then restarts it. Returns 0.0 for unused timers.
Definition at line 344 of file timing.c.
Referenced by auto_settlers_player(), blink_active_unit(), blink_turn_done_button(), cut_lagging_connection(), dai_manage_taxes(), handle_conn_pong(), incoming_client_packets(), increase_timeout_because_unit_moved(), load_command(), mapimg_create(), move_unit_map_canvas(), real_timer_callback(), save_game(), savegame3_save(), savegame_load(), send_game_info(), send_server_info_to_metaserver(), server_sniff_all_input(), set_mapview_origin(), sg_save_game(), srv_running(), update_animation(), and wait_for_requests().
struct timer * timer_renew | ( | struct timer * | t, |
enum timer_timetype | type, | ||
enum timer_use | use | ||
) |
Allocate a new timer, or reuse t, with specified "type" and "use". The timer is created as cleared, and stopped. If t is NULL, allocate and return a new timer, else just re-initialise t and return t. This is intended to be useful to allocate a static t just once, eg: { static struct timer *t = NULL; t = timer_renew(t, TIMER_CPU, TIMER_USE); ... stuff ... log_verbose("That took %g seconds.", timer_read_seconds(t)); ... never free t ... }
Definition at line 176 of file timing.c.
Referenced by animation_add(), auto_settlers_player(), autosaves_callback(), begin_phase(), blink_active_unit(), blink_turn_done_button(), cma_init(), decrease_unit_hp_smooth(), incoming_client_packets(), move_unit_map_canvas(), server_sniff_all_input(), set_mapview_origin(), set_seconds_to_turndone(), srv_running(), start_turn_change_wait(), timer_new(), update_animation(), and write_socket_data().
void timer_start | ( | struct timer * | t | ) |
Start timing, adding to previous accumulated time if timer has not been cleared. A warning is printed if the timer is already started.
Definition at line 224 of file timing.c.
Referenced by animation_add(), auto_settlers_player(), autosaves_callback(), begin_phase(), begin_search(), blink_active_unit(), blink_turn_done_button(), connection_ping(), dai_manage_taxes(), decrease_unit_hp_smooth(), incoming_client_packets(), load_command(), mapimg_create(), move_unit_map_canvas(), save_game(), savegame3_save(), savegame_load(), send_server_info_to_metaserver(), server_make_connection(), server_sniff_all_input(), set_mapview_origin(), set_seconds_to_turndone(), srv_running(), start_turn_change_wait(), timing_log_real(), update_animation(), wait_for_requests(), and write_socket_data().
void timer_stop | ( | struct timer * | t | ) |
Stop timing, and accumulate time so far. (The current time is stored in t->start, so that timer_read_seconds can call this to take a point reading if the timer is active.) A warning is printed if the timer is already stopped.
Definition at line 268 of file timing.c.
Referenced by autosaves_callback(), dai_manage_taxes(), end_search(), savegame3_save(), savegame_load(), timer_read_seconds(), timing_log_real(), and wait_for_requests().
void timer_usleep_since_start | ( | struct timer * | t, |
long | usec | ||
) |
Sleeps until the given number of microseconds have elapsed since the timer was started. Leaves the timer running. Must be called with an active, running user timer. (If timer is broken or in wrong state, just sleep for entire interval.)
Definition at line 364 of file timing.c.
Referenced by decrease_unit_hp_smooth().