jam: add commented-out functionality to count size of atom

This is a convenient way to count memory usage of noun by simplying
running `(jam 1.337 noun-1 noun-2 ... ~)`.  This should
be a hint, but for debugging this is sufficient.
This commit is contained in:
Philip Monk 2020-06-22 19:11:40 -07:00
parent fa6748a7e1
commit 6c3b7aeef5
No known key found for this signature in database
GPG Key ID: B66E1F02604E44EC

View File

@ -6,6 +6,40 @@
u3_noun
u3qe_jam(u3_atom a)
{
#if 0
if (c3y == u3du(a) && 1337 == u3h(a)) {
c3_w siz_w, tot_w = 0;
u3_noun som;
for ( som = u3t(a); c3y == u3du(som); som = u3t(som) ) {
siz_w = u3a_count_noun(u3h(som));
tot_w += siz_w;
if ( 0 == siz_w ) {
u3l_log("item: B/0\r\n");
}
else {
u3a_print_memory(stderr, "item", siz_w);
}
}
if ( u3_blip != som ) {
u3l_log("forgot to terminate list!\r\n");
}
c3_w mem_w = u3h_count(u3R->cax.har_p);
for ( som = u3t(a); c3y == u3du(som); som = u3t(som) ) u3a_discount_noun(u3h(som));
u3h_discount(u3R->cax.har_p);
u3a_print_memory(stderr, "total", tot_w);
u3a_print_memory(stderr, "memoization cache", mem_w);
u3h_root* har_u = u3to(u3h_root, u3R->cax.har_p);
u3l_log("memoization entries: %d\r\n", har_u->use_w);
c3_w diff = (u3R->hat_p < u3R->cap_p) ?
(u3R->cap_p - u3R->hat_p) :
(u3R->hat_p - u3R->cap_p);
u3a_print_memory(stderr, "unused free", diff);
return tot_w;
}
#endif
c3_w bit_w, *sal_w;
c3_w* wor_w = u3s_jam_fib(a, &bit_w);
c3_w len_w = bit_w >> 5;