[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
statistics for GC
From: |
Dave Love |
Subject: |
statistics for GC |
Date: |
26 Jan 2003 19:00:14 +0000 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.90 |
[Sorry if this is a duplicate -- I've had trouble sending out over the
weekend.]
I'd like to include something like this to allow measuring the GC
component when timing code. I can't think it's controversial unless
the names of the new variables aren't right.
I have benchmarking utilities that use it. It's probably useful for
ELP too, but I haven't looked at using it there.
Index: alloc.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/alloc.c,v
retrieving revision 1.290
diff -u -p -c -r1.290 alloc.c
cvs server: conflicting specifications of output style
*** alloc.c 24 Jan 2003 12:24:13 -0000 1.290
--- alloc.c 26 Jan 2003 18:53:46 -0000
*************** Lisp_Object Qgc_cons_threshold, Qchar_ta
*** 256,261 ****
--- 256,264 ----
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));
*************** Garbage collection happens automatically
*** 4085,4090 ****
--- 4088,4096 ----
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. */
*************** Garbage collection happens automatically
*** 4370,4376 ****
safe_run_hooks (Qpost_gc_hook);
unbind_to (count, Qnil);
}
!
return Flist (sizeof total / sizeof *total, total);
}
--- 4376,4391 ----
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);
}
*************** init_alloc ()
*** 5525,5530 ****
--- 5540,5547 ----
setjmp_tested_p = longjmps_done = 0;
#endif
#endif
+ Vgc_elapsed = make_float (0.0);
+ gcs_done = 0;
}
void
*************** which includes both saved text and other
*** 5613,5618 ****
--- 5630,5643 ----
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);
- statistics for GC,
Dave Love <=