Sort and print more info.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20785 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -2228,14 +2228,28 @@ static const char *statname[] = {
|
|||||||
"match time"
|
"match time"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct stat_el {
|
||||||
|
unsigned long stats;
|
||||||
|
unsigned int index;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
stat_sort(const void *a, const void *b)
|
||||||
|
{
|
||||||
|
const struct stat_el *ae = a;
|
||||||
|
const struct stat_el *be = b;
|
||||||
|
return be->stats - ae->stats;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
hx509_query_unparse_stats(hx509_context context, int printtype, FILE *out)
|
hx509_query_unparse_stats(hx509_context context, int printtype, FILE *out)
|
||||||
{
|
{
|
||||||
rtbl_t t;
|
rtbl_t t;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
int type, mask, i, num;
|
int type, mask, i, num;
|
||||||
unsigned long stats[32];
|
|
||||||
unsigned long multiqueries = 0, totalqueries = 0;
|
unsigned long multiqueries = 0, totalqueries = 0;
|
||||||
|
struct stat_el stats[32];
|
||||||
|
|
||||||
if (context->querystat == NULL)
|
if (context->querystat == NULL)
|
||||||
return;
|
return;
|
||||||
@@ -2245,15 +2259,19 @@ hx509_query_unparse_stats(hx509_context context, int printtype, FILE *out)
|
|||||||
context->querystat, strerror(errno));
|
context->querystat, strerror(errno));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memset(stats, 0, sizeof(stats));
|
|
||||||
|
|
||||||
|
for (i = 0; i < sizeof(stats)/sizeof(stats[0]); i++) {
|
||||||
|
stats[i].index = i;
|
||||||
|
stats[i].stats = 0;
|
||||||
|
}
|
||||||
|
|
||||||
while (fscanf(f, "%d %d\n", &type, &mask) == 2) {
|
while (fscanf(f, "%d %d\n", &type, &mask) == 2) {
|
||||||
if (type != printtype)
|
if (type != printtype)
|
||||||
continue;
|
continue;
|
||||||
num = i = 0;
|
num = i = 0;
|
||||||
while (mask && i < sizeof(stats)/sizeof(stats[0])) {
|
while (mask && i < sizeof(stats)/sizeof(stats[0])) {
|
||||||
if (mask & 1) {
|
if (mask & 1) {
|
||||||
stats[i]++;
|
stats[i].stats++;
|
||||||
num++;
|
num++;
|
||||||
}
|
}
|
||||||
mask = mask >>1 ;
|
mask = mask >>1 ;
|
||||||
@@ -2265,6 +2283,8 @@ hx509_query_unparse_stats(hx509_context context, int printtype, FILE *out)
|
|||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
|
qsort(stats, sizeof(stats)/sizeof(stats[0]), sizeof(stats[0]), stat_sort);
|
||||||
|
|
||||||
t = rtbl_create();
|
t = rtbl_create();
|
||||||
if (t == NULL)
|
if (t == NULL)
|
||||||
errx(1, "out of memory");
|
errx(1, "out of memory");
|
||||||
@@ -2278,18 +2298,21 @@ hx509_query_unparse_stats(hx509_context context, int printtype, FILE *out)
|
|||||||
for (i = 0; i < sizeof(stats)/sizeof(stats[0]); i++) {
|
for (i = 0; i < sizeof(stats)/sizeof(stats[0]); i++) {
|
||||||
char str[10];
|
char str[10];
|
||||||
|
|
||||||
if (i < sizeof(statname)/sizeof(statname[0]))
|
if (stats[i].index < sizeof(statname)/sizeof(statname[0]))
|
||||||
rtbl_add_column_entry_by_id (t, 0, statname[i]);
|
rtbl_add_column_entry_by_id (t, 0, statname[stats[i].index]);
|
||||||
else {
|
else {
|
||||||
snprintf(str, sizeof(str), "%d", i);
|
snprintf(str, sizeof(str), "%d", stats[i].index);
|
||||||
rtbl_add_column_entry_by_id (t, 0, str);
|
rtbl_add_column_entry_by_id (t, 0, str);
|
||||||
}
|
}
|
||||||
snprintf(str, sizeof(str), "%lu", stats[i]);
|
snprintf(str, sizeof(str), "%lu", stats[i].stats);
|
||||||
rtbl_add_column_entry_by_id (t, 1, str);
|
rtbl_add_column_entry_by_id (t, 1, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
rtbl_format(t, out);
|
rtbl_format(t, out);
|
||||||
rtbl_destroy(t);
|
rtbl_destroy(t);
|
||||||
|
|
||||||
|
fprintf(out, "\nQueries: multi %lu total %lu\n",
|
||||||
|
multiqueries, totalqueries);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
Reference in New Issue
Block a user