emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: funcall consing


From: Eli Zaretskii
Subject: Re: funcall consing
Date: Sun, 02 Jan 2022 16:46:02 +0200

> From: Tomas Hlavaty <tom@logand.com>
> Cc: emacs-devel@gnu.org
> Date: Sun, 02 Jan 2022 14:30:38 +0100
> 
> On Sat 01 Jan 2022 at 09:26, Eli Zaretskii <eliz@gnu.org> wrote:
> > Note that one of the examples posted by the OP does exactly twice GC
> > cycles that the other.  Which leads me to believe it had twice more
> > opportunities for checking how much consing was done.
> >
> > So I think the caveat not to put too much faith in the _number_ of GC
> > cycles is still something important to keep in mind.
> 
> In my example:
> 
> (benchmark-run 10 (dotimes (i 100000) (1+ i)))
> ;;(2.720941123 40 1.7525918699999998)
> (let ((x (lambda (i) (1+ i)))) (benchmark-run 10 (dotimes (i 100000) (funcall 
> x i))))
> ;;(4.9373091140000005 80 3.4835688719999958)
> 
> the third number is the time taken by garbage collection.  It is also
> roughly doubled for the second case indicating that the second case
> really generated more (say about twice as much) garbage.

The longer time taken by GC doesn't necessarily mean more garbage was
collected.  Scanning the same number of Lisp objects twice the number
of times will take roughly twice the time.

> Otherwise benchmark-run is not really useful for what I need.  In that
> case, what is the preferred way to measure execution speed and consing?

My suggestion is to examine and analyze the output of garbage-collect.
There are also the various *-cells-consed variables you could use.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]