[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: `add-face'
From: |
Lars Ingebrigtsen |
Subject: |
Re: `add-face' |
Date: |
Fri, 07 Sep 2012 16:13:10 +0200 |
User-agent: |
Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.2.50 (gnu/linux) |
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
- `add-face', Lars Ingebrigtsen, 2012/09/06
- Re: `add-face', Chong Yidong, 2012/09/07
- Re: `add-face', Lars Ingebrigtsen, 2012/09/07
- Re: `add-face', Chong Yidong, 2012/09/07
- Re: `add-face', Lars Ingebrigtsen, 2012/09/07
- Re: `add-face',
Lars Ingebrigtsen <=
- Re: `add-face', Chong Yidong, 2012/09/09
- Re: `add-face', Lars Ingebrigtsen, 2012/09/09
- Re: `add-face', Chong Yidong, 2012/09/09
- Re: `add-face', Stefan Monnier, 2012/09/10
Re: `add-face', Johan Bockgård, 2012/09/07