Statistics. More...
#include "internal.h"
#include <sys/time.h>
#include <unistd.h>
Go to the source code of this file.
Defines | |
#define | tm_USE_times 0 |
If true, use times() to collect timing statistics. | |
#define | tv_fmt "%.7f" |
#define | tv_fmt_s "%8.4f" |
#define | tv_fmt_args(V) (double) (V) |
Functions | |
static __inline double | tv_2_double (struct timeval *t) |
static void | _tm_print_utilization (const char *name, tm_type *t, size_t *n, int nn, size_t *sum) |
Print utilizations. | |
void | tm_print_stats () |
API: Print statistics. | |
void | tm_print_color_transition_stats () |
API: Print color transitions statistics. | |
void | tm_print_phase_transition_stats () |
API: Print phase transitions statistics. | |
void | tm_print_block_stats () |
API: Print block statistics. | |
void | tm_time_stat_print_ (tm_time_stat *ts, int flags, size_t *alloc_count_p) |
Print timing stats component. | |
void | tm_time_stat_begin (tm_time_stat *ts) |
Begin timing stats collection. | |
void | tm_time_stat_end (tm_time_stat *ts) |
End timing stats collection. | |
void | tm_print_time_stats () |
API: Print timing stats. |
Statistics.
Definition in file stats.c.
#define tm_USE_times 0 |
#define tv_fmt "%.7f" |
Referenced by tm_time_stat_print_().
#define tv_fmt_args | ( | V | ) | (double) (V) |
Referenced by tm_time_stat_print_().
#define tv_fmt_s "%8.4f" |
Referenced by tm_time_stat_print_().
static void _tm_print_utilization | ( | const char * | name, | |
tm_type * | t, | |||
size_t * | n, | |||
int | nn, | |||
size_t * | sum | |||
) | [static] |
Print utilizations.
Definition at line 33 of file stats.c.
References tm_type::size, tm, tm_abort(), tm_ALLOC, tm_B, tm_b, tm_b_NU, tm_BLACK, tm_color_name, tm_ECRU, tm_GREY, tm_msg(), tm_msg1(), tm_NU, tm_ROOT, tm_SCAN, tm_SWEEP, and tm_UNMARK.
Referenced by tm_print_stats().
00034 { 00035 int j; 00036 00037 tm_msg(name); 00038 00039 /* Compute total number of nodes in use. */ 00040 if ( nn > tm_NU ) { 00041 switch ( tm.phase ) { 00042 case tm_ALLOC: 00043 case tm_UNMARK: 00044 case tm_ROOT: 00045 case tm_SCAN: 00046 n[tm_NU] = n[tm_ECRU] + n[tm_GREY] + n[tm_BLACK]; 00047 break; 00048 00049 case tm_SWEEP: 00050 n[tm_NU] = n[tm_GREY] + n[tm_BLACK]; 00051 break; 00052 00053 default: 00054 tm_abort(); 00055 } 00056 if ( sum && sum != n ) 00057 sum[tm_NU] += n[tm_NU]; 00058 } 00059 00060 /* Compute total number of bytes in use. */ 00061 00062 if ( sum != n ) { 00063 if ( nn > tm_b ) { 00064 n[tm_b] = t ? n[tm_NU] * t->size : 0; 00065 if ( sum ) 00066 sum[tm_b] += n[tm_b]; 00067 } 00068 00069 /* Compute avg. bytes / node. */ 00070 if ( nn > tm_b_NU ) { 00071 n[tm_b_NU] = n[tm_NU] ? n[tm_b] / n[tm_NU] : 0; 00072 if ( sum ) 00073 sum[tm_b_NU] = sum[tm_NU] ? sum[tm_b] / sum[tm_NU] : 0; 00074 } 00075 00076 } 00077 00078 /* Print fields. */ 00079 for ( j = 0; j < nn; j ++ ) { 00080 if ( sum && sum != n && j <= tm_B ) { 00081 sum[j] += n[j]; 00082 } 00083 tm_msg1("%c%-4lu ", tm_color_name[j][0], (unsigned long) n[j]); 00084 } 00085 00086 tm_msg1("\n"); 00087 }
void tm_print_color_transition_stats | ( | ) |
API: Print color transitions statistics.
Definition at line 142 of file stats.c.
References tm_data::n_color_transitions, tm, tm_color_name, tm_msg(), tm_msg1(), tm_msg_enable(), and tm_TOTAL.
Referenced by tm_print_stats().
00143 { 00144 int i, j; 00145 00146 // tm_assert(sizeof(tm_color_name) / sizeof(tm_color_name[0]) >= tm_TOTAL + 1); 00147 00148 tm_msg_enable("C", 1); 00149 tm_msg("C { color transitions \n"); 00150 00151 tm_msg("C %-10s ", "from\\to"); 00152 for ( i = 0; i <= tm_TOTAL; ++ i ) { 00153 tm_msg1("%-10s ", tm_color_name[i]); 00154 } 00155 tm_msg1("\n"); 00156 00157 00158 for ( i = 0; i <= tm_TOTAL; ++ i ) { 00159 tm_msg("C %-10s ", tm_color_name[i]); 00160 for ( j = 0; j <= tm_TOTAL; ++ j ) { 00161 tm_msg1("%-10lu ", (unsigned long) tm.n_color_transitions[i][j]); 00162 } 00163 tm_msg1("\n"); 00164 } 00165 00166 tm_msg("C }\n"); 00167 tm_msg_enable("C", 0); 00168 }
void tm_print_phase_transition_stats | ( | ) |
API: Print phase transitions statistics.
Definition at line 175 of file stats.c.
References tm_data::n_phase_transitions, tm, tm_msg(), tm_msg1(), tm_msg_enable(), tm_phase_END, and tm_phase_name.
Referenced by tm_print_stats().
00176 { 00177 int i, j; 00178 00179 // tm_assert(sizeof(tm_phase_name) / sizeof(tm_phase_name[0]) == tm_phase_END + 1); 00180 00181 tm_msg_enable("P", 1); 00182 tm_msg("P { phase transitions \n"); 00183 00184 tm_msg("P %-10s ", "from\\to"); 00185 for ( i = 0; i <= tm_phase_END; ++ i ) { 00186 tm_msg1("%-10s ", tm_phase_name[i]); 00187 } 00188 tm_msg1("\n"); 00189 00190 00191 for ( i = 0; i <= tm_phase_END; ++ i ) { 00192 tm_msg("P %-10s ", tm_phase_name[i]); 00193 for ( j = 0; j <= tm_phase_END; ++ j ) { 00194 tm_msg1("%-10lu ", (unsigned long) tm.n_phase_transitions[i][j]); 00195 } 00196 tm_msg1("\n"); 00197 } 00198 00199 tm_msg("P }\n"); 00200 tm_msg_enable("P", 0); 00201 }
void tm_time_stat_begin | ( | tm_time_stat * | ts | ) |
Begin timing stats collection.
Definition at line 269 of file stats.c.
References tm_time_stat::t0, tm_time_stat::t01, and tv_2_double().
Referenced by __tm_write_barrier(), __tm_write_barrier_pure(), __tm_write_barrier_root(), _tm_alloc_type_inner(), _tm_gc_full_type_inner(), _tm_os_alloc(), _tm_os_free(), tm_alloc(), tm_alloc_desc(), tm_free(), tm_gc_full(), tm_realloc(), and tm_write_barrier_node().
00270 { 00271 #if tm_USE_times 00272 struct tms t0; 00273 times(&t0); 00274 ts->t0 = (double) t0.tms_utime / (double) CLOCKS_PER_SEC; 00275 ts->t01 = (double) t0.tms_stime / (double) CLOCKS_PER_SEC; 00276 #else 00277 struct timeval t0; 00278 gettimeofday(&t0, 0); 00279 ts->t0 = tv_2_double(&t0); 00280 #endif 00281 }
void tm_time_stat_end | ( | tm_time_stat * | ts | ) |
End timing stats collection.
Definition at line 287 of file stats.c.
References tm_time_stat::count, tm_time_stat::t0, tm_time_stat::t01, tm_time_stat::t1, tm_time_stat::t11, tm_time_stat::ta, tm_time_stat::td, tm_time_stat_print_(), tm_time_stat::ts, tv_2_double(), tm_time_stat::tw, and tm_time_stat::tw_changed.
Referenced by __tm_write_barrier(), __tm_write_barrier_pure(), __tm_write_barrier_root(), _tm_alloc_type_inner(), _tm_gc_full_type_inner(), _tm_os_alloc(), _tm_os_free(), tm_alloc(), tm_alloc_desc(), tm_free(), tm_gc_full(), tm_realloc(), and tm_write_barrier_node().
00288 { 00289 #if tm_USE_times 00290 { 00291 struct tms t1; 00292 times(&t1); 00293 ts->t1 = (double) t1.tms_utime / (double) CLOCKS_PER_SEC; 00294 ts->t11 = (double) t1.tms_stime / (double) CLOCKS_PER_SEC; 00295 } 00296 #else 00297 { 00298 struct timeval t1; 00299 gettimeofday(&t1, 0); 00300 ts->t1 = tv_2_double(&t1); 00301 } 00302 #endif 00303 00304 ++ ts->count; 00305 00306 /* Compute dt. */ 00307 ts->td = ts->t1 - ts->t0; 00308 #if tm_USE_times 00309 ts->td += ts->t11 - ts->t01; 00310 #endif 00311 00312 /* Compute sum of dt. */ 00313 ts->ts += ts->td; 00314 00315 /* Compute avg time. */ 00316 ts->ta = ts->ts / (double) ts->count; 00317 00318 /* Compute worst time. */ 00319 if ( (ts->tw_changed = ts->tw < ts->td) ) { 00320 ts->tw = ts->td; 00321 } 00322 00323 #if 0 00324 /* Print stats. */ 00325 tm_time_stat_print_(ts, ts->tw_changed ? 1 : 0, 0); 00326 #endif 00327 }
void tm_time_stat_print_ | ( | tm_time_stat * | ts, | |
int | flags, | |||
size_t * | alloc_count_p | |||
) |
Print timing stats component.
Definition at line 332 of file stats.c.
References tm_time_stat::count, tm_time_stat::name, tm_time_stat::ta, tm_time_stat::td, tm_msg(), tm_msg1(), tm_time_stat::ts, tv_fmt, tv_fmt_args, tv_fmt_s, and tm_time_stat::tw.
Referenced by tm_print_time_stats(), and tm_time_stat_end().
00333 { 00334 #define tv_fmt "%.7f" 00335 #define tv_fmt_s "%8.4f" 00336 #define tv_fmt_args(V) (double) (V) 00337 00338 tm_msg("T %-12s " 00339 , 00340 ts->name); 00341 00342 if ( ! (flags & (2|4)) ) { 00343 tm_msg1( 00344 " dt " tv_fmt 00345 , 00346 tv_fmt_args(ts->td) 00347 ); 00348 } 00349 00350 tm_msg1( 00351 " st " tv_fmt_s 00352 , 00353 tv_fmt_args(ts->ts) 00354 ); 00355 00356 if ( flags & 1 ) { 00357 tm_msg1( 00358 " wt " tv_fmt 00359 , 00360 tv_fmt_args(ts->tw) 00361 ); 00362 } 00363 00364 if ( flags & 2 ) { 00365 tm_msg1( 00366 " c %8lu" 00367 , 00368 (unsigned long) ts->count 00369 ); 00370 } 00371 00372 if ( flags & 4 ) { 00373 tm_msg1( 00374 " at %.7f" 00375 , 00376 (double) ts->ta 00377 ); 00378 } 00379 00380 if ( alloc_count_p ) { 00381 tm_msg1( 00382 " A %8lu" 00383 , 00384 (unsigned long) *alloc_count_p 00385 ); 00386 } 00387 00388 tm_msg1("\n"); 00389 }
static __inline double tv_2_double | ( | struct timeval * | t | ) | [static] |
Definition at line 22 of file stats.c.
Referenced by tm_time_stat_begin(), and tm_time_stat_end().