1#!/usr/bin/perl 2 3 4open(PROFILE,"profile.h") || die "Unable to open profile.h\n"; 5@profile = <PROFILE>; 6close PROFILE; 7 8open(METRICS,"> metrics.h") || die "Unable to open metrics.h for output\n"; 9 10print METRICS "#define COUNT_TIME_INDOM 0\n"; 11print METRICS "#define BYTE_INDOM 1\n\n"; 12print METRICS "#define FIELD_OFF(x) (unsigned)\&(((struct profile_stats *)NULL)->x)\n\n"; 13print METRICS "typedef struct {\n"; 14print METRICS "\tchar *name;\n"; 15print METRICS "\tunsigned offset;\n"; 16print METRICS "} samba_instance;\n\n"; 17 18@instnames = grep(/unsigned .*_time;/,@profile); 19foreach $instnames (@instnames) { 20 chomp $instnames; 21 $instnames =~ s/^.*unsigned (.*)_time.*$/$1/; 22} 23 24print METRICS "static samba_instance samba_counts[] = {"; 25$first = 1; 26foreach $1 (@instnames) { 27 if ($first == 1) { 28 $first = 0; 29 print METRICS "\n"; 30 } else { 31 print METRICS ",\n"; 32 } 33 print METRICS "\t{\"$1\", FIELD_OFF($1_count)}"; 34} 35print METRICS "\n};\n\n"; 36print METRICS "static samba_instance samba_times[] = {"; 37$first = 1; 38foreach $1 (@instnames) { 39 if ($first == 1) { 40 $first = 0; 41 print METRICS "\n"; 42 } else { 43 print METRICS ",\n"; 44 } 45 print METRICS "\t{\"$1\", FIELD_OFF($1_time)}"; 46} 47print METRICS "\n};\n\n"; 48print METRICS "static samba_instance samba_bytes[] = {"; 49@instnames = grep(/unsigned .*_bytes;/,@profile); 50$first = 1; 51foreach $_ (@instnames) { 52 if ($first == 1) { 53 $first = 0; 54 print METRICS "\n"; 55 } else { 56 print METRICS ",\n"; 57 } 58 /^.*unsigned (.*)_bytes.*$/; 59 print METRICS "\t{\"$1\", FIELD_OFF($1_bytes)}"; 60} 61print METRICS "\n};\n"; 62 63close METRICS 64