From: Eli Zaretskii <eliz@gnu.org>
To: ynyaaa@gmail.com
Cc: 23772@debbugs.gnu.org
Subject: bug#23772: 24.5; (format "%s" INTEGER) is slow
Date: Wed, 15 Jun 2016 17:59:28 +0300 [thread overview]
Message-ID: <834m8uebvz.fsf@gnu.org> (raw)
In-Reply-To: <87lh26y92j.fsf@gmail.com> (ynyaaa@gmail.com)
> From: ynyaaa@gmail.com
> Date: Wed, 15 Jun 2016 20:40:04 +0900
>
> (benchmark-run-compiled 100000 (format "%s" 0))
> =>(1.134 12 0.09000000000000119)
> (benchmark-run-compiled 100000 (format "%d" 0))
> =>(0.571 6 0.05500000000000016)
> (benchmark-run-compiled 100000 (format "%s" (format "%d" 0)))
> =>(0.652 13 0.12200000000000033)
Why is that a problem? %d is passed to sprintf, so it's very fast; %s
whose argument is a string or a symbol is also fast, because it just
copies characters. But %s with an argument that is neither a string
nor a symbol is implemented via a call to prin1-to-string, which is
more expensive because it produces a string representation of an
arbitrary Lisp object. This is consistent with your results.
IOW, if you know the argument is an integer, and you care about
performance, don't use %s.
prev parent reply other threads:[~2016-06-15 14:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-15 11:40 bug#23772: 24.5; (format "%s" INTEGER) is slow ynyaaa
2016-06-15 14:59 ` Eli Zaretskii [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=834m8uebvz.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=23772@debbugs.gnu.org \
--cc=ynyaaa@gmail.com \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.