emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: why is reverse a string in-place so much slower than a vector?


From: Leo Liu
Subject: Re: why is reverse a string in-place so much slower than a vector?
Date: Fri, 25 Apr 2014 16:17:42 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (CentOS 6.5)

On 2014-04-25 16:12 +0800, Leo Liu wrote:
> (defun rev (a)
>   (let ((l (length a)))
>     (dotimes (i (floor l 2) a)
>       (cl-rotatef (aref a i) (aref a (1- (- l i)))))))

Sorry didn't finish the post.

Assume we are in a buffer visiting subr.el:

(benchmark-run 1 (rev (buffer-string)))
(11.774416366 1 0.060193897999999635)

(benchmark-run 1 (rev (cl-coerce (buffer-string) 'vector)))
(0.067042623 0 0.0)

So why is this so much slower on string?

Leo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]