[Top][All Lists]

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

Re: How to measure frame rate in fps?

From: Eli Zaretskii
Subject: Re: How to measure frame rate in fps?
Date: Tue, 01 Jun 2021 14:43:31 +0300

> From: Jimmy Yuen Ho Wong <wyuenho@gmail.com>
> Date: Mon, 31 May 2021 14:03:17 +0100
> I've gotten into a discussion with isort's author about how fast
> editors can actually render text. I was just wondering if there are
> any built-in facilities that can measure framerate in FPS in emacs?

Emacs doesn't work at a fixed "frame rate".  It attempts to optimize
each update of the screen as much as possible, so the actual time to
perform a single update of a window depends on how much stuff on the
screen needs to be changed since the previous redisplay cycle.  As
result, you will find that the redisplay time could vary by a factor
of 10 if not more, depending on what changed in the editor's internal
state.  Moreover, the first phase of redisplay, the one that
determines what needs to be redrawn, might decide to redraw something,
but the second phase, which actually writes to the glass, can decide
that nothing needs to be redrawn.  I don't know how to quantify the
speed of "redrawing" when nothing is actually redrawn, although some
CPU cycles are expended.

That said, you can measure the time it takes to redisplay after some
change using the "M-x benchmark" command to time the function
'redisplay'.  You just need to remember to include some command that
would affect the display, or else redisplay will do very little and
redraw nothing.  For example:

  C-u 100 M-x benchmark RET (progn (scroll-up) (redisplay)) RET


  C-u 100 M-x benchmark RET (progn (insert "a") (redisplay)) RET

(The former is better tried in a buffer that has more than 100
screenfuls of text.)

Then subtract the time it takes to run the same benchmark, but without
the "(redisplay)" part, divide the result by 100, and you get the time
it takes to redisplay a single window.

reply via email to

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