unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Arthur Miller <arthur.miller@live.com>
To: emacs-devel@gnu.org
Subject: Image transforms as a benchmark?
Date: Sun, 12 Sep 2021 13:45:39 +0200	[thread overview]
Message-ID: <AM9PR09MB497767C7F6D2AC76C5D1C08496D89@AM9PR09MB4977.eurprd09.prod.outlook.com> (raw)


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



             reply	other threads:[~2021-09-12 11:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-12 11:45 Arthur Miller [this message]
2021-09-12 12:12 ` Image transforms as a benchmark? 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AM9PR09MB497767C7F6D2AC76C5D1C08496D89@AM9PR09MB4977.eurprd09.prod.outlook.com \
    --to=arthur.miller@live.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).