From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.devel Subject: Re: `add-face' Date: Fri, 07 Sep 2012 16:13:10 +0200 Organization: Programmerer Ingebrigtsen Message-ID: <87mx11hqfd.fsf@gnus.org> References: <87harbgnez.fsf@gnus.org> <87wr06tqj9.fsf@gnu.org> <87wr06gg30.fsf@gnus.org> <87pq5yq7sb.fsf@gnu.org> <87r4qegd3w.fsf@gnus.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1347027238 21580 80.91.229.3 (7 Sep 2012 14:13:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 7 Sep 2012 14:13:58 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 07 16:14:01 2012 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1T9zJi-0004T8-Vk for ged-emacs-devel@m.gmane.org; Fri, 07 Sep 2012 16:13:55 +0200 Original-Received: from localhost ([::1]:43541 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T9zJf-0003fR-Q6 for ged-emacs-devel@m.gmane.org; Fri, 07 Sep 2012 10:13:51 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:52177) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T9zJR-0003c1-0N for emacs-devel@gnu.org; Fri, 07 Sep 2012 10:13:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T9zJI-0006Tu-QX for emacs-devel@gnu.org; Fri, 07 Sep 2012 10:13:36 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:46354) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T9zJI-0006TK-Ir for emacs-devel@gnu.org; Fri, 07 Sep 2012 10:13:28 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1T9zJF-0003qD-Ga for emacs-devel@gnu.org; Fri, 07 Sep 2012 16:13:25 +0200 Original-Received: from ip-200-13-149-91.dialup.ice.net ([91.149.13.200]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 07 Sep 2012 16:13:25 +0200 Original-Received: from larsi by ip-200-13-149-91.dialup.ice.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 07 Sep 2012 16:13:25 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: emacs-devel@gnu.org Original-Lines: 39 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: ip-200-13-149-91.dialup.ice.net Mail-Copies-To: never X-Now-Playing: Isotope 217's _The Unstable Molecule_ User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.2.50 (gnu/linux) Cancel-Lock: sha1:hS0L34qT1sDLkkaae2h4U9R4a1E= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:153147 Archived-At: I've now done some simple benchmarking with the native function and the next-property-change version, included below. Setting a thousand face properties on a biggish web page isn't unusual. With a hundred repetitions, the native version takes 12 seconds. The non-native one takes 91 seconds. So on a realistic shr.el rendering, fontifying with the native version takes 0.12 seconds, while the non-native ones takes 0.91 seconds, so this seems worthwhile to me. Especially with such a small change to the C code. Shall I just check the code in, and then we can fiddle with it further? (defun add-props-native () (with-temp-buffer (dotimes (i 1000) (insert "this is a line of text and stuff\n")) (dotimes (i 1000) (let* ((start (1+ (random (1- (buffer-size))))) (length (random (- (buffer-size) start)))) (add-face-text-property start (+ start length) (if (zerop (mod length 2)) 'bold 'italic)))))) (defun add-props-non-native () (with-temp-buffer (dotimes (i 1000) (insert "this is a line of text and stuff\n")) (dotimes (i 1000) (let* ((start (1+ (random (1- (buffer-size))))) (length (random (- (buffer-size) start)))) (add-face start (+ start length) (if (zerop (mod length 2)) 'bold 'italic)))))) -- (domestic pets only, the antidote for overdose, milk.) http://lars.ingebrigtsen.no * Lars Magne Ingebrigtsen