27 #define NUM_UPDATE_RECORDS 5
30 typedef struct mr_info {
40 int records_second[NUM_UPDATE_RECORDS];
41 int records_second_count;
46 int records_frame[NUM_UPDATE_RECORDS];
47 int records_frame_count;
72 memset(&Multi_rate[np_index][idx], 0,
sizeof(mr_info));
73 Multi_rate[np_index][
idx].stamp_second = -1;
86 if((type == NULL) || (strlen(type) <= 0)){
93 if(strlen(Multi_rate[np_index][idx].type) <= 0){
97 else if(!
stricmp(Multi_rate[np_index][idx].type, type)){
103 if(idx >= MAX_RATE_TYPES){
108 m = &Multi_rate[np_index][
idx];
114 m->total_bytes +=
size;
117 m->bytes_second +=
size;
120 m->bytes_frame +=
size;
127 #define R_AVG(ct, ar, avg) do {int av_idx; float av_sum = 0.0f; if(ct == 0){ avg = 0;} else { for(av_idx=0; av_idx<ct; av_idx++){ av_sum += (float)ar[av_idx]; } avg = av_sum / (float)ct; } }while(0)
136 m = &Multi_rate[
idx][s_idx];
139 if(strlen(m->type) <= 0){
144 if(m->stamp_second == -1){
148 if(m->records_second_count >= NUM_UPDATE_RECORDS){
149 memmove(m->records_second, m->records_second+1,
sizeof(
int) * (NUM_UPDATE_RECORDS - 1));
150 m->records_second[NUM_UPDATE_RECORDS-1] = m->bytes_second;
154 m->records_second[m->records_second_count++] = m->bytes_second;
158 R_AVG(m->records_second_count, m->records_second, m->avg_second);
167 if(m->records_frame_count >= NUM_UPDATE_RECORDS){
168 memmove(m->records_frame, m->records_frame+1,
sizeof(
int) * (NUM_UPDATE_RECORDS - 1));
169 m->records_frame[NUM_UPDATE_RECORDS-1] = m->bytes_frame;
173 m->records_frame[m->records_frame_count++] = m->bytes_frame;
177 R_AVG(m->records_frame_count, m->records_frame, m->avg_frame);
193 if((np_index < 0) || (np_index >= MAX_RATE_PLAYERS)){
199 m = &Multi_rate[np_index][
idx];
202 if(strlen(m->type) <= 0){
208 gr_printf_no_resize(x, y,
"%s %d (%d/s) (%f/f)", m->type, m->total_bytes, (
int)m->avg_second, m->avg_frame);
int timestamp(int delta_ms)
void gr_set_color_fast(color *dst)
void multi_rate_reset(int np_index)
GLint GLint GLint GLint GLint x
int multi_rate_add(int np_index, char *type, int size)
#define timestamp_elapsed(stamp)
#define MAX_RATE_TYPE_LEN
void _cdecl gr_printf_no_resize(int x, int y, const char *format,...)
void multi_rate_display(int np_index, int x, int y)
void multi_rate_process()