void dump_header (tabstop *t) { print_fill("name", t->name); print_fill("min(us)", t->min); print_fill("max(us)", t->max); print_fill("mean(us)", t->mean); print_fill("median(us)", t->median); print_fill("total(us)", t->total); print_fill("hits(us)", t->hits); putc('\n', out); }
void spy_dump_internal (spy_t s, tabstop *t) { long average = 0; long median = 0; long std_var; long n_samples; if (s->n == 0) return; n_samples = s->n > s->n_samples ? s->n_samples : s->n; open_output(); average = spy_average(s); median = spy_median(s); std_var = spy_std_variation(s); if (!(mode & SPY_DISPLAY_CYCLES)) { print_fill(s->name, t->name); print_fill(r_dtoa(cycle_to_usec(s->min)), t->min); print_fill(r_dtoa(cycle_to_usec(s->max)), t->max); print_fill(r_dtoa(cycle_to_usec(average)), t->mean); print_fill(r_dtoa(cycle_to_usec(median)), t->median); print_fill(r_dtoa(cycle_to_usec(s->cumulative)), t->total); print_fill(itoa(s->n), t->hits); putc('\n', out); } else { fprintf(out, "%-9s: %5ld(%5.2f), %5ld(%5.2f), %5ld(%5.2f), %5ld(%5.2f), %5ld(%5.2f), %5ld.\n", s->name, s->min, cycle_to_usec(s->min), s->max, cycle_to_usec(s->max), average, cycle_to_usec(average), median, cycle_to_usec(median), s->cumulative, cycle_to_usec(s->cumulative), s->n); } close_output(); }
static int print_format(char **buffer, const char *format, void *var) { unsigned long start; unsigned int i = 0, sizei = 0, len = 0, length_mod = sizeof(int); unsigned long value = 0; unsigned long signBit; char *form, sizec[32]; char sign = ' '; bool upper = false; form = (char *) format; start = (unsigned long) *buffer; form++; if(*form == '0' || *form == '.') { sign = '0'; form++; } while(*form != '\0') { switch(*form) { case 'u': case 'd': case 'i': sizec[i] = '\0'; value = (unsigned long) var; signBit = 0x1ULL << (length_mod * 8 - 1); if ((*form != 'u') && (signBit & value)) { **buffer = '-'; *buffer += 1; value = (-(unsigned long)value) & convert[length_mod]; } print_fill(buffer, sizec, value, 10, sign, 0); print_itoa(buffer, value, 10, upper); break; case 'X': upper = true; case 'x': sizec[i] = '\0'; value = (unsigned long) var & convert[length_mod]; print_fill(buffer, sizec, value, 16, sign, 0); print_itoa(buffer, value, 16, upper); break; case 'O': case 'o': sizec[i] = '\0'; value = (long int) var & convert[length_mod]; print_fill(buffer, sizec, value, 8, sign, 0); print_itoa(buffer, value, 8, upper); break; case 'p': sizec[i] = '\0'; print_fill(buffer, sizec, (unsigned long) var, 16, ' ', 2); **buffer = '0'; *buffer += 1; **buffer = 'x'; *buffer += 1; print_itoa(buffer,(unsigned long) var, 16, upper); break; case 'c': sizec[i] = '\0'; print_fill(buffer, sizec, 1, 10, ' ', 0); **buffer = (unsigned long) var; *buffer += 1; break; case 's': sizec[i] = '\0'; sizei = strtoul(sizec, NULL, 10); len = strlen((char *) var); if(sizei > len) { for(i = 0; i < (sizei - len); i++) { **buffer = ' '; *buffer += 1; } } for(i = 0; i < strlen((char *) var); i++) { **buffer = ((char *) var)[i]; *buffer += 1; } break; case 'l': form++; if(*form == 'l') { length_mod = sizeof(long long int); } else { form--; length_mod = sizeof(long int); } break; case 'h': form++; if(*form == 'h') { length_mod = sizeof(signed char); } else { form--; length_mod = sizeof(short int); } break; case 'z': length_mod = sizeof(size_t); break; default: if(*form >= '0' && *form <= '9') sizec[i++] = *form; } form++; } return (long int) (*buffer - start); }