- From: Xavier Beaudouin <kiwi AT cvs.caudiumforge.net>
- To: caudium-commits AT caudium.net
- Subject: CVS: caudium/src/cmods/_Caudium test_mem.pike,NONE,1.1 caudium.c,1.141,1.142
- Date: Tue, 20 Jul 2004 13:03:45 +0200
Update of /cvs/caudium/caudium/src/cmods/_Caudium
In directory cvs.caudiumforge.net:/tmp/cvs-serv40406/src/cmods/_Caudium
Modified Files:
caudium.c
Added Files:
test_mem.pike
Log Message:
_Caudium.program_object_memory_usage() function for all of us...
Vida you'll will be happy to find what is growing on Camas now :p
***** Error reading new file[Errno 2] No such file or directory:
'test_mem.pike'
Index: caudium.c
===================================================================
RCS file: /cvs/caudium/caudium/src/cmods/_Caudium/caudium.c,v
retrieving revision 1.141
retrieving revision 1.142
diff -u -r1.141 -r1.142
--- caudium.c 25 May 2004 14:35:45 -0000 1.141
+++ caudium.c 20 Jul 2004 11:03:43 -0000 1.142
@@ -18,11 +18,11 @@
*
*/
/*
- * $Id: caudium.c,v 1.141 2004/05/25 14:35:45 vida Exp $
+ * $Id: caudium.c,v 1.142 2004/07/20 11:03:43 kiwi Exp $
*/
#include "global.h"
-RCSID("$Id: caudium.c,v 1.141 2004/05/25 14:35:45 vida Exp $");
+RCSID("$Id: caudium.c,v 1.142 2004/07/20 11:03:43 kiwi Exp $");
#include "caudium_util.h"
#include "caudium_machine.h"
#include "entparse.h"
@@ -71,7 +71,7 @@
/*
**! file: Caudium/caudium.c
**! Caudium specific classes and functions.
-**! cvs_version: $Id: caudium.c,v 1.141 2004/05/25 14:35:45 vida Exp $
+**! cvs_version: $Id: caudium.c,v 1.142 2004/07/20 11:03:43 kiwi Exp $
*/
/*
@@ -1830,6 +1830,38 @@
push_string(ret);
}
+/* Function to count memory usage */
+/* From Grubba */
+static void f_program_object_memory_usage(INT32 args)
+{
+ struct mapping *m;
+ struct svalue o_sv;
+
+ pop_n_elems(args);
+ /*push_mapping(m = allocate_mapping(num_program)); */
+ push_mapping(m =
allocate_mapping(Pike_compiler->new_program->num_program));
+
+ o_sv.type = PIKE_T_OBJECT;
+ o_sv.subtype = 0;
+
+ for (o_sv.u.object = first_object; o_sv.u.object;
+ o_sv.u.object = o_sv.u.object->next) {
+ struct svalue *val;
+ if (!o_sv.u.object->prog || !o_sv.u.object->prog->storage_needed)
+ continue;
+ if ((val = low_mapping_lookup(m, &o_sv))) {
+#ifdef PIKE_DEBUG
+ if (val->type != PIKE_T_INT) Pike_fatal("...\n");
+#endif /* PIKE_DEBUG */
+ val->u.integer += o_sv.u.object->prog->storage_needed;
+ } else {
+ push_int(o_sv.u.object->prog->storage_needed);
+ mapping_insert(m, &o_sv, Pike_sp-1);
+ pop_stack();
+ }
+ }
+}
+
/* Initialize and start module */
void pike_module_init( void )
@@ -1913,6 +1945,11 @@
"function(mapping:mapping)", 0);
add_function_constant( "xml_encode_mapping", f_xml_encode_mapping,
"function(mapping:mapping)", 0);
+ /* Function to get memory info */
+
+ add_function_constant( "program_object_memory_usage",
f_program_object_memory_usage,
+ "function(void:mapping)", 0);
+
init_datetime();
start_new_program();
- CVS: caudium/src/cmods/_Caudium test_mem.pike,NONE,1.1 caudium.c,1.141,1.142, Xavier Beaudouin
Archive powered by MhonArc 2.6.10.