--- deliantra/server/common/time.C 2006/08/15 18:07:24 1.2 +++ deliantra/server/common/time.C 2006/08/24 13:13:48 1.3 @@ -1,6 +1,6 @@ /* * static char *rcsid_time_c = - * "$Id: time.C,v 1.2 2006/08/15 18:07:24 root Exp $"; + * "$Id: time.C,v 1.3 2006/08/24 13:13:48 root Exp $"; */ /* @@ -39,17 +39,9 @@ /* * Gloabal variables: */ -long max_time = MAX_TIME; -struct timeval last_time; -#define PBUFLEN 100 -long process_utime_save[PBUFLEN]; long psaveind; -long process_max_utime = 0; -long process_min_utime = 999999999; -long process_tot_mtime; long pticks; -long process_utime_long_count; const char *season_name[] = { @@ -91,68 +83,6 @@ "Month of Gorokh" }; -/* - * Initialise all variables used in the timing routines. - */ - -void -reset_sleep(void) -{ - int i; - for(i = 0; i < PBUFLEN; i++) - process_utime_save[i] = 0; - psaveind = 0; - process_max_utime = 0; - process_min_utime = 999999999; - process_tot_mtime = 0; - pticks = 0; - - (void) GETTIMEOFDAY(&last_time); -} - -void -log_time(long process_utime) -{ - pticks++; - if (++psaveind >= PBUFLEN) - psaveind = 0; - process_utime_save[psaveind] = process_utime; - if (process_utime > process_max_utime) - process_max_utime = process_utime; - if (process_utime < process_min_utime) - process_min_utime = process_utime; - process_tot_mtime += process_utime/1000; -} - -/* - * enough_elapsed_time will return true if the time passed since - * last tick is more than max-time. - */ - -int -enough_elapsed_time(void) -{ - static struct timeval new_time; - long elapsed_utime; - - (void) GETTIMEOFDAY(&new_time); - - elapsed_utime = (new_time.tv_sec - last_time.tv_sec) * 1000000 + - new_time.tv_usec - last_time.tv_usec; - if (elapsed_utime > max_time) { - log_time(elapsed_utime); - last_time.tv_sec = new_time.tv_sec; - last_time.tv_usec = new_time.tv_usec; - return 1; - } - return 0; -} - -void -set_max_time(long t) { - max_time = t; -} - extern unsigned long todtick; void @@ -211,48 +141,6 @@ new_draw_info(NDI_UNIQUE, 0,op,errmsg); } -void -time_info(object *op) -{ - int tot = 0, maxt = 0, mint = 99999999, long_count = 0, i; - - print_tod(op); - if (!QUERY_FLAG(op,FLAG_WIZ)) - return; - - new_draw_info (NDI_UNIQUE, 0,op,"Total time:"); - sprintf(errmsg,"ticks=%ld time=%ld.%2ld", - pticks, process_tot_mtime/1000, process_tot_mtime%1000); - new_draw_info (NDI_UNIQUE, 0,op,errmsg); - sprintf(errmsg,"avg time=%ldms max time=%ldms min time=%ldms", - process_tot_mtime/pticks, process_max_utime/1000, - process_min_utime/1000); - new_draw_info (NDI_UNIQUE, 0,op,errmsg); - sprintf(errmsg,"ticks longer than max time (%ldms) = %ld (%ld%%)", - max_time/1000, - process_utime_long_count, 100*process_utime_long_count/pticks); - new_draw_info (NDI_UNIQUE, 0,op,errmsg); - - sprintf(errmsg,"Time last %ld ticks:", pticks > PBUFLEN ? PBUFLEN : pticks); - new_draw_info (NDI_UNIQUE, 0,op,errmsg); - - for (i = 0; i < (pticks > PBUFLEN ? PBUFLEN : pticks); i++) { - tot += process_utime_save[i]; - if (process_utime_save[i] > maxt) maxt = process_utime_save[i]; - if (process_utime_save[i] < mint) mint = process_utime_save[i]; - if (process_utime_save[i] > max_time) long_count++; - } - - sprintf(errmsg,"avg time=%ldms max time=%dms min time=%dms", - tot/(pticks > PBUFLEN ? PBUFLEN : pticks)/1000, maxt/1000, - mint/1000); - new_draw_info (NDI_UNIQUE, 0,op,errmsg); - sprintf(errmsg,"ticks longer than max time (%ldms) = %d (%ld%%)", - max_time/1000, long_count, - 100*long_count/(pticks > PBUFLEN ? PBUFLEN : pticks)); - new_draw_info (NDI_UNIQUE, 0,op,errmsg); -} - long seconds(void) {