unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Image transforms as a benchmark?
@ 2021-09-12 11:45 Arthur Miller
  2021-09-12 12:12 ` Alan Third
  2021-09-12 12:17 ` Eli Zaretskii
  0 siblings, 2 replies; 7+ messages in thread
From: Arthur Miller @ 2021-09-12 11:45 UTC (permalink / raw)
  To: emacs-devel


I tried to make another little benchmark, I saw with optimization flags, that
quite some loops have got unrolled and vectorized in image.c, so I wanted to see
if it matters when doing some transforms on images. I tested so far just with
svg.

I wonder if image-rotate is handled completely by external libraries? I see
no effect on performance, regardless of how many time I rotate some image. Is it
same situation for scaling down? I see big difference when scaling up images so
I guess that is handled by Emacs own code?

#+begin_src emacs-lisp
(require 'svg)

(defun svg-position (image)
  "Return buffer position of the svg image."
  (let ((marker (cdr (assoc :image (car-safe (cdr image))))))
    (when (markerp marker)
      (marker-position marker))))

(defun svg-image-rotate (svg &optional angle)
  (let ((image (image--get-image (svg-position svg))))
    (setf (image-property image :rotation)
          (float (mod (+ (or (image-property image :rotation) 0)
                         (or angle 90))
                      360)))))

(defun svg-increase-size ()
  (with-temp-buffer
    (let ((svg (svg-create 10 10))
          (max-image-size t))
      (svg-rectangle svg 0 0 10 10)
      (svg-insert-image svg)
      (dotimes (_ 40)
      ;; use internal image--change-size
      ;; to bypass the optimization with idle-timer.
        (image--change-size
         (1+ (/ (prefix-numeric-value 2) 10.0))
         (svg-position svg))))))

(defun svg-decrease-size ()
  (with-temp-buffer
    (let ((svg (svg-create 10 10)))
      (svg-rectangle svg 0 0 10 10)
      (svg-insert-image svg)
      (dotimes (_ 20)
        (image--change-size
         (- 1 (/ (prefix-numeric-value 0.1) 10.0))
         (svg-position svg))))))
#+end_src



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

end of thread, other threads:[~2021-09-12 17:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-12 11:45 Image transforms as a benchmark? Arthur Miller
2021-09-12 12:12 ` Alan Third
2021-09-12 13:28   ` Arthur Miller
2021-09-12 15:50     ` Alan Third
2021-09-12 17:50       ` Arthur Miller
2021-09-12 12:17 ` Eli Zaretskii
2021-09-12 13:29   ` Arthur Miller

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