Hello,
I have been working on evaluating/integrating a Lisp based testing
framework into Axiom (based on Lift). One of the features is the
ability to benchmark the running of tests.
To accommodate the benchmark code, I needed a function which returns
the total number of bytes allocated since the image was started.
I could not find such a function. Perhaps I missed it? There is
SI:ALLOCATED, but it reports information for a specific type only.
I considered writing a function using SI:ALLOCATED and SI:SIZE-OF for
personal use. However, when I considered if such a function would be
of use to GCL, I realized it may be better to attempt it in C.
Of course, if the facility already exists, then this is just a
learning experience for me. Attached is a patch against alloc.c.
I have two issues with this code:
* Is it correct to assume that all entries in tm_table with the
tm_size field equal share the same allocation space? I assumed
this from the documentation for SI:ALLOCATED.
* Im slightly concerned about overflow of the `bytes' variable. Is
this likely? Should bignum arith be used?
Hopefully this might be of some use to GCL, however I completely
understand if it is deemed unnecessary, badly implemented, etc.
Sincerely,
Steve
--- alloc.c 2007-07-04 14:54:42.000000000 -0400
+++ alloc.c.smw 2007-07-10 20:54:56.000000000 -0400
@@ -547,7 +547,24 @@
RV(make_fixnum(tm->tm_nused))
));
}
-
+
+DEFUN_NEW("TOTAL-BYTES-ALLOCATED",object,fStotal_bytes_allocated,SI,0,0,NONE,OO,OO,OO,OO,(void),"")
+{int i,j;
+ bool counted;
+ long bytes = 0;
+ for(i=t_start; i < t_end; i++) {
+ counted = FALSE;
+ for(j=t_start; j < i; j++)
+ if (tm_table[i].tm_size == tm_table[j].tm_size) {
+ counted = TRUE;
+ break;
+ }
+ if (!counted)
+ bytes += tm_table[i].tm_size * tm_table[i].tm_nused;
+ }
+ RETURN1(make_fixnum(bytes));
+}
+
DEFUN_NEW("RESET-NUMBER-USED",object,fSreset_number_used,SI,0,1,NONE,OO,OO,OO,OO,(object typ),"")
{int i;
if (VFUN_NARGS == 1)
_______________________________________________
Axiom-developer mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/axiom-developer