Permalink
Switch branches/tags
android-wear-5.1.1_r1 android-wear-5.1.0_r1 android-wear-5.0.0_r1 android-sdk-support_r11 android-sdk-adt_r20 android-sdk-adt_r16.0.1 android-sdk-4.4.2_r1.0.1 android-sdk-4.4.2_r1 android-sdk-4.0.3_r1 android-sdk-4.0.3-tools_r1 android-l-preview_r2 android-cts-verifier-4.0.3_r1 android-cts-verifier-4.0_r1 android-cts-5.1_r25 android-cts-5.1_r24 android-cts-5.1_r23 android-cts-5.1_r22 android-cts-5.1_r21 android-cts-5.1_r20 android-cts-5.1_r19 android-cts-5.1_r18 android-cts-5.1_r17 android-cts-5.1_r16 android-cts-5.1_r15 android-cts-5.1_r14 android-cts-5.1_r13 android-cts-5.1_r10 android-cts-5.1_r9 android-cts-5.1_r8 android-cts-5.1_r7 android-cts-5.1_r6 android-cts-5.1_r5 android-cts-5.1_r4 android-cts-5.1_r3 android-cts-5.1_r2 android-cts-5.1_r1 android-cts-5.0_r9 android-cts-5.0_r8 android-cts-5.0_r7 android-cts-5.0_r6 android-cts-5.0_r5 android-cts-5.0_r4 android-cts-5.0_r3 android-cts-4.4_r4 android-cts-4.4_r1 android-cts-4.2_r2 android-cts-4.2_r1 android-cts-4.1_r4 android-cts-4.1_r2 android-cts-4.1_r1 android-cts-4.0.3_r2 android-cts-4.0.3_r1 android-cts-4.0_r1 android-cts-2.3_r12 android-cts-2.3_r11 android-cts-2.3_r10 android-cts-2.2_r8 android-5.1.1_r38 android-5.1.1_r37 android-5.1.1_r36 android-5.1.1_r35 android-5.1.1_r34 android-5.1.1_r33 android-5.1.1_r30 android-5.1.1_r29 android-5.1.1_r28 android-5.1.1_r26 android-5.1.1_r25 android-5.1.1_r24 android-5.1.1_r23 android-5.1.1_r22 android-5.1.1_r20 android-5.1.1_r19 android-5.1.1_r18 android-5.1.1_r17 android-5.1.1_r16 android-5.1.1_r15 android-5.1.1_r14 android-5.1.1_r13 android-5.1.1_r12 android-5.1.1_r10 android-5.1.1_r9 android-5.1.1_r8 android-5.1.1_r7 android-5.1.1_r6 android-5.1.1_r5 android-5.1.1_r4 android-5.1.1_r3 android-5.1.1_r2 android-5.1.1_r1 android-5.1.0_r5 android-5.1.0_r4 android-5.1.0_r3 android-5.1.0_r1 android-5.0.2_r3 android-5.0.2_r1 android-5.0.1_r1 android-5.0.0_r7 android-5.0.0_r6 android-5.0.0_r5.1
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
89 lines (72 sloc) 2.24 KB
/**
* @file db_stat.c
* Statistics routines for libdb
*
* @remark Copyright 2002 OProfile authors
* @remark Read the file COPYING
*
* @author Philippe Elie
*/
#include <stdlib.h>
#include <stdio.h>
#include "odb.h"
#include "op_types.h"
/// hold various statistics data for a db file
struct odb_hash_stat_t {
odb_node_nr_t node_nr; /**< allocated node number */
odb_node_nr_t used_node_nr; /**< in use node number */
count_type total_count; /**< cumulated samples count */
odb_index_t hash_table_size; /**< hash table entry number */
odb_node_nr_t max_list_length; /**< worst case */
double average_list_length; /**< average case */
/* do we need variance ? */
};
odb_hash_stat_t * odb_hash_stat(odb_t const * odb)
{
size_t max_length = 0;
double total_length = 0.0;
size_t nr_non_empty_list = 0;
size_t pos;
odb_data_t * data = odb->data;
odb_hash_stat_t * result = calloc(1, sizeof(odb_hash_stat_t));
if (!result) {
fprintf(stderr, "not enough memory\n");
exit(EXIT_FAILURE);
}
result->node_nr = data->descr->size;
result->used_node_nr = data->descr->current_size;
result->hash_table_size = data->descr->size * BUCKET_FACTOR;
/* FIXME: I'm dubious if this do right statistics for hash table
* efficiency check */
for (pos = 0 ; pos < result->hash_table_size ; ++pos) {
size_t cur_length = 0;
size_t index = data->hash_base[pos];
while (index) {
result->total_count += data->node_base[index].value;
index = data->node_base[index].next;
++cur_length;
}
if (cur_length > max_length)
max_length = cur_length;
if (cur_length) {
total_length += cur_length;
++nr_non_empty_list;
}
}
result->max_list_length = max_length;
result->average_list_length = total_length / nr_non_empty_list;
return result;
}
void odb_hash_display_stat(odb_hash_stat_t const * stat)
{
printf("total node number: %d\n", stat->node_nr);
printf("total used node: %d\n", stat->used_node_nr);
printf("total count: %llu\n", stat->total_count);
printf("hash table size: %d\n", stat->hash_table_size);
printf("greater list length: %d\n", stat->max_list_length);
printf("average non empty list length: %2.4f\n", stat->average_list_length);
}
void odb_hash_free_stat(odb_hash_stat_t * stat)
{
free(stat);
}