From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: How to measure frame rate in fps? Date: Tue, 01 Jun 2021 14:43:31 +0300 Message-ID: <83h7ih24kc.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1828"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Jimmy Yuen Ho Wong Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Jun 01 13:44:36 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lo2oy-0000BM-6Y for ged-emacs-devel@m.gmane-mx.org; Tue, 01 Jun 2021 13:44:32 +0200 Original-Received: from localhost ([::1]:51934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lo2ox-0001IA-78 for ged-emacs-devel@m.gmane-mx.org; Tue, 01 Jun 2021 07:44:31 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo2oH-0000XU-Hr for emacs-devel@gnu.org; Tue, 01 Jun 2021 07:43:49 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:53542) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lo2oH-0002jz-Ar; Tue, 01 Jun 2021 07:43:49 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4916 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lo2oG-0005Lm-UO; Tue, 01 Jun 2021 07:43:49 -0400 In-Reply-To: (message from Jimmy Yuen Ho Wong on Mon, 31 May 2021 14:03:17 +0100) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:270191 Archived-At: > From: Jimmy Yuen Ho Wong > 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 or 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.