summaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorkr.angelov <kr.angelov@gmail.com>2012-11-12 15:36:21 +0000
committerkr.angelov <kr.angelov@gmail.com>2012-11-12 15:36:21 +0000
commit7ad4436502543b34879910cc8998b93baf81c0ad (patch)
tree4a0367c6207c7317a0bdce6a6347d92a10ed442f /src/runtime
parent9b2487243ea28320555a5449530a7f0fd8362e0a (diff)
more counters in the profiler for the statistical parser
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/c/pgf/parser.c58
1 files changed, 47 insertions, 11 deletions
diff --git a/src/runtime/c/pgf/parser.c b/src/runtime/c/pgf/parser.c
index 14ee8c705..fbe3d8f94 100644
--- a/src/runtime/c/pgf/parser.c
+++ b/src/runtime/c/pgf/parser.c
@@ -48,8 +48,11 @@ typedef struct {
PgfProduction meta_prod;
int max_fid;
#ifdef PGF_COUNTS_DEBUG
- int item_count;
- int real_count;
+ int item_full_count;
+ int item_real_count;
+ int cont_full_count;
+ int ccat_full_count;
+ int prod_full_count;
#endif
PgfItem* free_item;
} PgfParsing;
@@ -480,6 +483,12 @@ pgf_parsing_get_conts(PgfContsMap* conts_map,
conts->items = gu_new_buf(PgfItem*, pool);
conts->ref_count = 0;
gu_list_index(contss, lin_idx) = conts;
+
+#ifdef PGF_COUNTS_DEBUG
+ if (state != NULL) {
+ state->ps->cont_full_count++;
+ }
+#endif
}
return conts;
}
@@ -511,6 +520,11 @@ pgf_parsing_create_completed(PgfParseState* state, PgfItemConts* conts,
cat->prods = gu_buf_seq(gu_new_buf(PgfProduction, state->pool));
cat->n_synprods = 0;
gu_map_put(state->generated_cats, conts, PgfCCat*, cat);
+
+#ifdef PGF_COUNTS_DEBUG
+ state->ps->ccat_full_count++;
+#endif
+
return cat;
}
@@ -635,8 +649,8 @@ pgf_new_item(PgfItemConts* conts, PgfProduction prod,
#ifdef PGF_COUNTS_DEBUG
if (ps != NULL) {
- ps->item_count++;
- ps->real_count++;
+ ps->item_full_count++;
+ ps->item_real_count++;
}
#endif
@@ -657,8 +671,8 @@ pgf_item_copy(PgfItem* item, GuPool* pool, PgfParsing* ps)
#ifdef PGF_COUNTS_DEBUG
if (ps != NULL) {
- ps->item_count++;
- ps->real_count++;
+ ps->item_full_count++;
+ ps->item_real_count++;
}
#endif
@@ -730,7 +744,7 @@ pgf_item_free(PgfParseState* before, PgfParseState* after,
item->next = before->ps->free_item;
before->ps->free_item = item;
#ifdef PGF_COUNTS_DEBUG
- before->ps->real_count--;
+ before->ps->item_real_count--;
#endif
}
@@ -937,6 +951,9 @@ pgf_parsing_complete(PgfParseState* before, PgfParseState* after,
{
PgfProduction prod =
pgf_parsing_new_production(item, ep, before->pool);
+#ifdef PGF_COUNTS_DEBUG
+ before->ps->prod_full_count++;
+#endif
PgfCCat* tmp_cat = pgf_parsing_get_completed(before, item->conts);
PgfCCat* cat = tmp_cat;
@@ -1596,8 +1613,11 @@ pgf_new_parsing(PgfConcr* concr, GuPool* pool)
ps->target = NULL;
ps->max_fid = concr->total_cats;
#ifdef PGF_COUNTS_DEBUG
- ps->item_count = 0;
- ps->real_count = 0;
+ ps->item_full_count = 0;
+ ps->item_real_count = 0;
+ ps->cont_full_count = 0;
+ ps->ccat_full_count = 0;
+ ps->prod_full_count = 0;
#endif
ps->free_item = NULL;
@@ -1648,11 +1668,23 @@ pgf_new_token_state(PgfConcr *concr, PgfToken tok, GuPool* pool)
return ts;
}
+#ifdef PGF_COUNTS_DEBUG
+void pgf_parsing_print_counts(PgfParsing* ps)
+{
+ printf("%d\t%d\t%d\t%d\t%d\n",
+ ps->item_full_count,
+ ps->item_real_count,
+ ps->cont_full_count,
+ ps->ccat_full_count,
+ ps->prod_full_count);
+}
+#endif
+
PgfParseState*
pgf_parser_next_state(PgfParseState* prev, PgfToken tok, GuPool* pool)
{
#ifdef PGF_COUNTS_DEBUG
- printf("%d\t%d\n", prev->ps->item_count, prev->ps->real_count);
+ pgf_parsing_print_counts(prev->ps);
#endif
PgfTokenState* ts =
@@ -1850,7 +1882,7 @@ PgfExprEnum*
pgf_parse_result(PgfParseState* state, GuPool* pool)
{
#ifdef PGF_COUNTS_DEBUG
- printf("%d\t%d\n", state->ps->item_count, state->ps->real_count);
+ pgf_parsing_print_counts(state->ps);
#endif
GuPool* tmp_pool = gu_new_pool();
@@ -1900,6 +1932,10 @@ pgf_parser_init_state(PgfConcr* concr, PgfCId cat, size_t lin_idx, GuPool* pool)
conts->items = gu_new_buf(PgfItem*, pool);
conts->ref_count = 0;
gu_buf_push(conts->items, PgfItem*, NULL);
+
+#ifdef PGF_COUNTS_DEBUG
+ ps->cont_full_count++;
+#endif
size_t n_prods = gu_seq_length(ccat->prods);
for (size_t i = 0; i < n_prods; i++) {