[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GNU AUCTeX branch, master, updated. 34befcc17649fd6615fd4ef8756fb787
From: |
Tassilo Horn |
Subject: |
Re: GNU AUCTeX branch, master, updated. 34befcc17649fd6615fd4ef8756fb78705f7fe55 |
Date: |
Wed, 23 Feb 2022 12:56:35 +0100 |
User-agent: |
mu4e 1.7.9; emacs 29.0.50 |
Arash Esbati <arash@gnu.org> writes:
>> Yes, the performance aspect. The annotation function might be called
>> hundredth or thousands of times, and appending lists is expensive.
>>
>> ;; The current version
>> (benchmark 10000
>> '(LaTeX--completion-annotation-from-math-menu "aleph"))
>> "Elapsed time: 0.136648s"
>>
>> ;; Your proposed version
>> (benchmark 10000
>> '(LaTeX--completion-annotation-from-math-menu-with-append
>> "aleph"))
>> "Elapsed time: 2.190776s (1.388426s in 18 GCs)"
>>
>> So here it would almost be a factor of 20 slower.
>
> Thanks for your responses. I was aware of `append' being expensive,
> but I didn't expect the hit being so large for this case.
Me neither but I do get those numbers with this definition (and the
current emacs master):
--8<---------------cut here---------------start------------->8---
(defun LaTeX--completion-annotation-from-math-menu-with-append (sym)
(catch 'found
(dolist (e (append LaTeX-math-list LaTeX-math-default))
(let ((val (cadr e)))
(when (and (stringp val)
(string= val sym))
(let ((char (nth 3 e)))
(when char
(throw 'found
(concat " " (char-to-string char))))))))))
--8<---------------cut here---------------end--------------->8---
What makes me very curious is that LaTeX-math-list is `nil' so that
`append' needs to copy the first list should be a non-issue here. And
in fact, `benchmark' suggest appending those two concrete lists is
faster than building a 2-element list containing the values of both
variables which makes sense:
--8<---------------cut here---------------start------------->8---
(benchmark 1000000
'(list LaTeX-math-list LaTeX-math-default))
"Elapsed time: 0.607044s (0.490079s in 6 GCs)"
(benchmark 1000000
'(append LaTeX-math-list LaTeX-math-default))
"Elapsed time: 0.170943s"
--8<---------------cut here---------------end--------------->8---
So how can the original benchmarking result be true?
Well, the answer is that I've benchmarked a compiled vs. an interpreted
function. After evaluating
(byte-compile 'LaTeX--completion-annotation-from-math-menu-with-append)
the runtimes of the benchmarks are about the same with slight advantages
for the version using `append'. I guess as soon as `LaTeX-math-list'
has two or more items, it'll tip over to the double-dolist variant.
Bye,
Tassilo
- Re: GNU AUCTeX branch, master, updated. 34befcc17649fd6615fd4ef8756fb78705f7fe55, Arash Esbati, 2022/02/22
- Re: GNU AUCTeX branch, master, updated. 34befcc17649fd6615fd4ef8756fb78705f7fe55, Tassilo Horn, 2022/02/22
- Re: GNU AUCTeX branch, master, updated. 34befcc17649fd6615fd4ef8756fb78705f7fe55, Arash Esbati, 2022/02/23
- Re: GNU AUCTeX branch, master, updated. 34befcc17649fd6615fd4ef8756fb78705f7fe55,
Tassilo Horn <=
- Re: GNU AUCTeX branch, master, updated. 34befcc17649fd6615fd4ef8756fb78705f7fe55, Arash Esbati, 2022/02/23
- Re: GNU AUCTeX branch, master, updated. 34befcc17649fd6615fd4ef8756fb78705f7fe55, Tassilo Horn, 2022/02/23
- Re: GNU AUCTeX branch, master, updated. 34befcc17649fd6615fd4ef8756fb78705f7fe55, Arash Esbati, 2022/02/23
- Re: GNU AUCTeX branch, master, updated. 34befcc17649fd6615fd4ef8756fb78705f7fe55, Tassilo Horn, 2022/02/23
- Re: GNU AUCTeX branch, master, updated. 34befcc17649fd6615fd4ef8756fb78705f7fe55, Tassilo Horn, 2022/02/24
Re: GNU AUCTeX branch, master, updated. 34befcc17649fd6615fd4ef8756fb78705f7fe55, David Kastrup, 2022/02/22