Mercurial > emacs
changeset 49529:fd79b3081e01
(Vgc_elapsed, gcs_done): New variables.
(Fgarbage_collect): Use them.
(init_alloc, syms_of_alloc): Set them up.
author | Dave Love <fx@gnu.org> |
---|---|
date | Thu, 30 Jan 2003 14:15:58 +0000 |
parents | bbee23d72342 |
children | 4746ab25c458 |
files | src/alloc.c |
diffstat | 1 files changed, 29 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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);