aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorDmitry Antipov2012-07-29 17:51:45 +0400
committerDmitry Antipov2012-07-29 17:51:45 +0400
commitdbcf001cd7877a7f03a9307afbb82190b24bc356 (patch)
treef88ddb975b8cceb20b645edecf24a2ceff30d7d8 /src/alloc.c
parente2688e4ac71bd3c1f7d22f28175c4ca81eb87e43 (diff)
downloademacs-dbcf001cd7877a7f03a9307afbb82190b24bc356.tar.gz
emacs-dbcf001cd7877a7f03a9307afbb82190b24bc356.zip
Cleanup statistics calculation in Fgarbage_collect.
* alloc.c (Fgarbage_collect): Rename t1 to meaningful start. Fix zombies percentage calculation. Simplify elapsed time calculation.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/alloc.c b/src/alloc.c
index e5f412bb4c3..625acad991c 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -5437,7 +5437,7 @@ See Info node `(elisp)Garbage Collection'. */)
5437 int message_p; 5437 int message_p;
5438 Lisp_Object total[11]; 5438 Lisp_Object total[11];
5439 ptrdiff_t count = SPECPDL_INDEX (); 5439 ptrdiff_t count = SPECPDL_INDEX ();
5440 EMACS_TIME t1; 5440 EMACS_TIME start;
5441 5441
5442 if (abort_on_gc) 5442 if (abort_on_gc)
5443 abort (); 5443 abort ();
@@ -5454,7 +5454,7 @@ See Info node `(elisp)Garbage Collection'. */)
5454 FOR_EACH_BUFFER (nextb) 5454 FOR_EACH_BUFFER (nextb)
5455 compact_buffer (nextb); 5455 compact_buffer (nextb);
5456 5456
5457 t1 = current_emacs_time (); 5457 start = current_emacs_time ();
5458 5458
5459 /* In case user calls debug_print during GC, 5459 /* In case user calls debug_print during GC,
5460 don't let that cause a recursive GC. */ 5460 don't let that cause a recursive GC. */
@@ -5706,18 +5706,16 @@ See Info node `(elisp)Garbage Collection'. */)
5706#if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES 5706#if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES
5707 { 5707 {
5708 /* Compute average percentage of zombies. */ 5708 /* Compute average percentage of zombies. */
5709 double nlive = 0; 5709 double nlive =
5710 5710 total_conses + total_symbols + total_markers + total_strings
5711 for (i = 0; i < 7; ++i) 5711 + total_vectors + total_floats + total_intervals + total_buffers;
5712 if (CONSP (total[i]))
5713 nlive += XFASTINT (XCAR (total[i]));
5714 5712
5715 avg_live = (avg_live * ngcs + nlive) / (ngcs + 1); 5713 avg_live = (avg_live * ngcs + nlive) / (ngcs + 1);
5716 max_live = max (nlive, max_live); 5714 max_live = max (nlive, max_live);
5717 avg_zombies = (avg_zombies * ngcs + nzombies) / (ngcs + 1); 5715 avg_zombies = (avg_zombies * ngcs + nzombies) / (ngcs + 1);
5718 max_zombies = max (nzombies, max_zombies); 5716 max_zombies = max (nzombies, max_zombies);
5719 ++ngcs; 5717 ++ngcs;
5720 } 5718 }
5721#endif 5719#endif
5722 5720
5723 if (!NILP (Vpost_gc_hook)) 5721 if (!NILP (Vpost_gc_hook))
@@ -5729,12 +5727,9 @@ See Info node `(elisp)Garbage Collection'. */)
5729 5727
5730 /* Accumulate statistics. */ 5728 /* Accumulate statistics. */
5731 if (FLOATP (Vgc_elapsed)) 5729 if (FLOATP (Vgc_elapsed))
5732 { 5730 Vgc_elapsed = make_float
5733 EMACS_TIME t2 = current_emacs_time (); 5731 (XFLOAT_DATA (Vgc_elapsed) + EMACS_TIME_TO_DOUBLE
5734 EMACS_TIME t3 = sub_emacs_time (t2, t1); 5732 (sub_emacs_time (current_emacs_time (), start)));
5735 Vgc_elapsed = make_float (XFLOAT_DATA (Vgc_elapsed)
5736 + EMACS_TIME_TO_DOUBLE (t3));
5737 }
5738 5733
5739 gcs_done++; 5734 gcs_done++;
5740 5735