# HG changeset patch # User Dave Love # Date 1043936158 0 # Node ID fd79b3081e01b638aecc65b2758667501d841e13 # Parent bbee23d72342b2d791286a354684235d0d17b4de (Vgc_elapsed, gcs_done): New variables. (Fgarbage_collect): Use them. (init_alloc, syms_of_alloc): Set them up. diff -r bbee23d72342 -r fd79b3081e01 src/alloc.c --- a/src/alloc.c Thu Jan 30 07:21:10 2003 +0000 +++ b/src/alloc.c Thu Jan 30 14:15:58 2003 +0000 @@ -256,6 +256,9 @@ Lisp_Object Vpost_gc_hook, Qpost_gc_hook; +Lisp_Object Vgc_elapsed; /* accumulated elapsed time in GC */ +EMACS_INT gcs_done; /* accumulated GCs */ + static void mark_buffer P_ ((Lisp_Object)); static void mark_kboards P_ ((void)); static void gc_sweep P_ ((void)); @@ -645,8 +648,8 @@ elsewhere in the code should be inside a BLOCK_INPUT/UNBLOCK_INPUT pairs; unfortunately, we have no idea what C library functions might call malloc, so we can't really protect them unless you're - using GNU malloc. Fortunately, most of the major operating can use - GNU malloc. */ + using GNU malloc. Fortunately, most of the major operating systems + can use GNU malloc. */ #ifndef SYSTEM_MALLOC #ifndef DOUG_LEA_MALLOC @@ -1236,7 +1239,7 @@ return nbytes; } -/* Check validity Lisp strings' string_bytes member in B. */ +/* Check validity of Lisp strings' string_bytes member in B. */ void check_sblock (b) @@ -4085,6 +4088,9 @@ int message_p; Lisp_Object total[8]; int count = SPECPDL_INDEX (); + EMACS_TIME t1, t2, t3; + + EMACS_GET_TIME (t1); /* Can't GC if pure storage overflowed because we can't determine if something is a pure object or not. */ @@ -4370,7 +4376,16 @@ safe_run_hooks (Qpost_gc_hook); unbind_to (count, Qnil); } - + + /* Accumulate statistics. */ + EMACS_GET_TIME (t2); + EMACS_SUB_TIME (t3, t2, t1); + if (FLOATP (Vgc_elapsed)) + XSETFLOAT (Vgc_elapsed, make_float (XFLOAT_DATA (Vgc_elapsed) + + EMACS_SECS (t3) + + EMACS_USECS (t3) * 1.0e-6)); + gcs_done++; + return Flist (sizeof total / sizeof *total, total); } @@ -5525,6 +5540,8 @@ setjmp_tested_p = longjmps_done = 0; #endif #endif + Vgc_elapsed = make_float (0.0); + gcs_done = 0; } void @@ -5614,6 +5631,14 @@ staticpro (&Qchar_table_extra_slots); Qchar_table_extra_slots = intern ("char-table-extra-slots"); + DEFVAR_LISP ("gc-elapsed", &Vgc_elapsed, + doc: /* Accumulated time elapsed in garbage collections. +The time is in seconds as a floating point value. +Programs may reset this to get statistics in a specific period. */); + DEFVAR_INT ("gcs-done", &gcs_done, + doc: /* Accumulated number of garbage collections done. +Programs may reset this to get statistics in a specific period. */); + defsubr (&Scons); defsubr (&Slist); defsubr (&Svector);