19 #if defined(CALCULATE_STATS_ON_QUERY)
21 #define DEBUG_MAX_CHAIN_SIZE 10000000
22 #define DEBUG_MAX_CHAIN_NAME_DIST 99999
23 #define DEBUG_TREE_DEPTH (PT_POS_TREE_HEIGHT+1)
28 if (i == imax)
return true;
29 if (i<20)
return true;
30 if (i<100)
return (i%10) == 9;
31 if (i<1000)
return (i%100) == 99;
32 if (i<10000)
return (i%1000) == 999;
33 if (i<100000)
return (i%10000) == 9999;
34 if (i<1000000)
return (i%100000) == 99999;
35 if (i<10000000)
return (i%1000000) == 999999;
85 splits[height][basecnt]++;
99 const char *ptr = ((
char*)pt)+1;
100 const char *next = ptr;
102 next = next + (pt->
flags&1 ? 4 : 2);
chm.
apos += (next-ptr); ptr = next;
112 int nameDist = thisName-lastName;
114 ++chain_name_dist[nameDist];
122 size_t mem = iter.
memptr()-(
char*)pt;
124 chains_of_size[size]++;
125 chains_of_size_mem[size] += mem;
126 chains_at_depth[height]++;
127 chains_at_depth_mem[height] += mem;
136 printf(
"%10zu mem:%7s mean:%5.2f b", count,
GBS_readable_size(mem,
"b"), mem/
double(count));
139 printf(
"%10zu (=%5.2f%%) mem:%7s (=%5.2f%%) mean:%5.2f b",
140 count, count*100.0/all,
145 void LF() { putchar(
'\n'); }
160 printf(
" [%i]=%-10zu", j, k);
165 fputs(
"nodes (all): ", stdout);
printCountAndMem(sum, mem); printf(
" (%5.2f%%)\n", mem*100.0/indexsize);
177 fputs(
"tips (all): ", stdout);
printCountAndMem(sum, mem); printf(
" (%5.2f%%)\n", mem*100.0/indexsize);
182 size_t k = chains_at_depth[i];
185 mem += chains_at_depth_mem[i];
189 fputs(
"chains (all): ", stdout);
printCountAndMem(sum, mem); printf(
" (%5.2f%%)\n", mem*100.0/indexsize);
192 #if defined(ASSERTION_USED)
193 size_t chain_mem1 = mem;
196 size_t chain_sum = 0;
200 size_t k = chains_of_size[i];
206 mem += chains_of_size_mem[i];
210 int first_skipped = 0;
218 if (!show && !first_skipped) {
223 size_t k = chains_of_size[i];
229 m_sum += chains_of_size_mem[i];
234 if (first_skipped) printf(
"chain of size %7i-%7i", first_skipped, i);
235 else printf(
"chain of size %15i", i);
237 printf(
" occur %10zu (%5.2f%%) entries:", k_sum, k_sum*100.0/chain_sum);
250 fputs(
"ch.entries (all): ", stdout);
printCountAndMem(sum, mem); printf(
" (%5.2f%%)\n", mem*100.0/indexsize);
255 size_t followup_chain_entries = 0;
257 followup_chain_entries += chain_name_dist[i];
261 int first_skipped = 0;
266 if (!show && !first_skipped) {
271 k_sum += chain_name_dist[i];
274 if (first_skipped) printf(
"chain-entry-name-dist of %5i-%5i", first_skipped, i);
275 else printf(
"chain-entry-name-dist of %11i", i);
277 double pc = k_sum*100.0/followup_chain_entries;
280 printf(
" occurs %10zu (=%5.2f%%; sum=%5.2f%%)\n", k_sum, pc, pcsum);
287 printf(
"overall followup-chain-entries: %zu\n", followup_chain_entries);
292 printf(
"Chain header summary:\n"
296 printf(
" all %s (=%5.2f%%) mean:%5.2f b\n",
GBS_readable_size(allhead,
"b"), allhead *100.0/mem,
double(allhead) /
chm.
flag);
299 size_t known_other_mem =
307 allmem += known_other_mem;
312 if (indexsize>allmem) {
315 else if (indexsize<allmem) {
319 puts(
"indexsize exactly matches counted memory");
327 #if defined(CALCULATE_STATS_ON_QUERY)
333 stat->
dump(filesize);
345 PT_dump_loc(
const char *Prefix, FILE *Out) : prefix(Prefix), out(Out) {}
360 fprintf(out,
"{x} %s [saved]\n", prefix);
364 fprintf(out,
"{?} %s [undefined]\n", prefix);
372 PT *son = PT_read_son<PT>(pt,
PT_base(b));
380 else if (pt->is_leaf()) {
386 else if (pt->is_chain()) {
404 fprintf(out,
"node father %p\n",
node->get_father());
406 switch (
node->get_type()) {
413 for (
long i = 0; i <
PT_BASES; i++) {
418 fputs(
"chain:\n", out);
419 PTD_chain_print chainPrinter;
423 fputs(
"saved:\n", out);
426 fputs(
"<invalid node type>\n", out);
434 FILE *dump = fopen(dumpfile,
"wt");
446 fprintf(stderr,
"Note: index has been dumped to '%s'\n", dumpfile);
451 const char *outfile = main->dumpname;
size_t tips_mem[DEBUG_TREE_DEPTH]
size_t PT_leaf_size(POS_TREE2 *node)
size_t splits[DEBUG_TREE_DEPTH][PT_BASES]
size_t chains_at_depth[DEBUG_TREE_DEPTH]
void PT_dump_POS_TREE_recursive(PT *pt, const char *prefix, FILE *out)
static void PT_dump_POS_TREE_to_file(const char *dumpfile)
POS_TREE1 *& TREE_ROOT1()
void analyse(POS_TREE2 *pt, int height)
struct PT_statistic::chain_head_mem chm
int PT_forwhole_chain(PT *node, T &func)
int main(int argc, char **argv)
GB_ERROR GB_IO_error(const char *action, const char *filename)
void dump(size_t indexsize)
#define DEBUG_MAX_CHAIN_SIZE
size_t tips[DEBUG_TREE_DEPTH]
int PT_index_dump(const PT_main *main)
static bool show_for_index(int i, int imax)
#define DEBUG_MAX_CHAIN_NAME_DIST
long GB_size_of_file(const char *path)
const probe_input_data & get_pid() const
size_t nodes[DEBUG_TREE_DEPTH]
void GBK_terminate(const char *error) __ATTR__NORETURN
int operator()(const DataLoc &loc)
void printCountAndMem(size_t count, size_t mem)
const char * GBS_readable_size(unsigned long long size, const char *unit_suffix)
size_t nodes_mem[DEBUG_TREE_DEPTH]
void printCountPercentAndMem(size_t count, size_t all, size_t mem, size_t allmem)
const AbsLoc & at() const
size_t chains_at_depth_mem[DEBUG_TREE_DEPTH]
int operator()(const AbsLoc &loc)
PT * PT_read_son(PT *node, PT_base base)
CONSTEXPR_INLINE char base_2_readable(char base)
fputs(TRACE_PREFIX, stderr)
void dump_POS_TREE_special(PT *pt, const char *prefix, FILE *out)
size_t chains_of_size_mem[DEBUG_MAX_CHAIN_SIZE+1]
PT_dump_loc(const char *Prefix, FILE *Out)
POS_TREE2 *& TREE_ROOT2()
void PT_dump_tree_statistics(const char *indexfilename)
size_t PT_node_size(POS_TREE2 *node)
size_t chain_name_dist[DEBUG_MAX_CHAIN_NAME_DIST+1]
size_t chains_of_size[DEBUG_MAX_CHAIN_SIZE+1]
void PT_dump_POS_TREE(POS_TREE1 *IF_DEBUG(node), FILE *IF_DEBUG(out))
const char * memptr() const
char * GBS_global_string_copy(const char *templat,...)