unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* string_char_to_byte and string_byte_to_char micro-optimisation
@ 2019-06-14 12:37 Robert Pluim
  2019-06-14 16:53 ` Paul Eggert
  0 siblings, 1 reply; 9+ messages in thread
From: Robert Pluim @ 2019-06-14 12:37 UTC (permalink / raw)
  To: emacs-devel

Hi,

in <https://nullprogram.com/blog/2019/05/29/> a benchmark is shown:

(defun compare (string-a string-b)
  (cl-loop for a being the elements of string-a
           for b being the elements of string-b
           unless (eql a b)
           return (cons a b)))
(benchmark-run
    (let ((a (make-string 100000 0))
          (b (make-string 100000 0)))
      (setf (aref a (1- (length a))) 256
            (aref b (1- (length b))) 256)
      (compare a b)))

which runs very slowly because string_char_to_byte and
string_byte_to_char only cache the found values for 1 previous string.

I have a patch which extends this cache to two (count 'em, two!)
previous strings, which fixes this particular benchmark.

What I donʼt have is any intuition on whether such a change actually
makes any difference in real-world Emacs usage. Can anyone suggest any
benchmarks?

Thanks

Robert



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-06-17  9:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-14 12:37 string_char_to_byte and string_byte_to_char micro-optimisation Robert Pluim
2019-06-14 16:53 ` Paul Eggert
2019-06-14 19:00   ` Eli Zaretskii
2019-06-14 20:11     ` Stefan Monnier
2019-06-15  6:22       ` Eli Zaretskii
2019-06-15  7:48         ` Stefan Monnier
2019-06-15 11:11           ` Noam Postavsky
2019-06-16 11:17             ` Stefan Monnier
2019-06-17  9:37   ` Robert Pluim

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).