aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.txt1
-rw-r--r--src/crunch.c28
2 files changed, 24 insertions, 5 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 7c5cbe8..31bac3c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,5 +1,6 @@
0.3.0:
- alf's compression speed is now acceptable: 14x as fast as 0.2.1.
+- alf now has -v (verbose) flag, also -vv and -vvv for more verbosity.
0.2.1 (never released):
diff --git a/src/crunch.c b/src/crunch.c
index 2369db5..66c55fa 100644
--- a/src/crunch.c
+++ b/src/crunch.c
@@ -66,22 +66,35 @@ char *fmt_chr(u8 c) {
return buf;
}
+void indent(int level) {
+ int i;
+
+ for(i = 0; i < level; i++)
+ fputs(" ", stdout);
+}
+
+int maxkidcount = 0, maxlevel = 0, totalkidcount = 0;
void dump_kids(token_t *t, int level) {
token_t *kid;
- int i;
+ int kidcount =0;
+
+ if(level > maxlevel) maxlevel = level;
if(t->kids) {
kid = t->kids;
while(kid) {
- for(i = 0; i < level; i++)
- fputs(" ", stdout);
+ kidcount++;
+ totalkidcount++;
+ indent(level);
printf("#%d/%s\n", kid->number, fmt_chr(kid->chr));
dump_kids(kid, level + 1);
kid = kid->sibling;
}
+ indent(level - 1);
+ printf("#%d has %d kids\n", t->number, kidcount);
+ if(kidcount > maxkidcount) maxkidcount = kidcount;
} else {
- for(i = 0; i < level; i++)
- fputs(" ", stdout);
+ indent(level);
fputs("(no kids)\n", stdout);
}
}
@@ -89,12 +102,17 @@ void dump_kids(token_t *t, int level) {
void dump_tokens(void) {
int i;
+ maxkidcount = maxlevel = totalkidcount = 0;
+
for(i = 0; i < 256; i++) {
if(root_tokens[i].kids) {
printf("root_tokens[%s], #%d\n", fmt_chr(root_tokens[i].chr), root_tokens[i].number);
dump_kids(&root_tokens[i], 1);
}
}
+
+ printf("maxkidcount %d, maxlevel = %d, totalkidcount = %d\n", maxkidcount, maxlevel, totalkidcount);
+ printf("avgkidcount: %.2f\n", ((float)totalkidcount) / (float)(curr_token - INIT_TOKEN));
}
void inc_output_len(void) {