From: Lars Ingebrigtsen <larsi@gnus.org>
To: emacs-devel@gnu.org
Subject: Re: `add-face'
Date: Fri, 07 Sep 2012 16:13:10 +0200 [thread overview]
Message-ID: <87mx11hqfd.fsf@gnus.org> (raw)
In-Reply-To: 87r4qegd3w.fsf@gnus.org
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
next prev parent reply other threads:[~2012-09-07 14:13 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-06 15:51 `add-face' Lars Ingebrigtsen
2012-09-07 4:17 ` `add-face' Chong Yidong
2012-09-07 12:41 ` `add-face' Lars Ingebrigtsen
2012-09-07 13:31 ` `add-face' Chong Yidong
2012-09-07 13:46 ` `add-face' Lars Ingebrigtsen
2012-09-07 14:13 ` Lars Ingebrigtsen [this message]
2012-09-09 6:47 ` `add-face' Chong Yidong
2012-09-09 17:31 ` `add-face' Lars Ingebrigtsen
2012-09-10 3:07 ` `add-face' Chong Yidong
2012-09-10 12:57 ` `add-face' Stefan Monnier
2012-10-24 18:56 ` `add-face' Lars Magne Ingebrigtsen
2013-06-17 7:54 ` `add-face' Lars Magne Ingebrigtsen
2013-06-17 9:12 ` `add-face' Lars Magne Ingebrigtsen
2013-06-17 9:51 ` `add-face' Lars Magne Ingebrigtsen
2013-06-17 14:43 ` `add-face' Stefan Monnier
2013-06-17 15:29 ` `add-face' Lars Magne Ingebrigtsen
2012-10-24 18:54 ` `add-face' Lars Magne Ingebrigtsen
2012-09-07 20:10 ` `add-face' Johan Bockgård
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mx11hqfd.fsf@gnus.org \
--to=larsi@gnus.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).